我对身份验证 GReader 编辑 API 有疑问。我可以使用 HTTPS (https://www.google.com/accounts/ClientLogin) 进行身份验证,谷歌返回三个令牌(SID、LSID、AUTH),但没有 HSID。
当我尝试添加一个新的提要http://www.google.com/reader/api/0/subscription/quickadd?ck=1290452912454&client=scroll POST 数据 T=djj72HsnLS8293&quickadd=blog.martindoms.com/feed/ 没有HSID Cookie,是响应状态码 401。使用 Cookie 中的 SID 和 HSID 一切正常。
这个 HSID 字符串是什么以及在哪里可以找到?
谢谢你的回答。
我的代码:
public void addNewFeed() throws IOException {
HttpPost requestPost = new HttpPost("http://www.google.com/reader/api/0/subscription/quickadd?ck=1290452912454&client=scroll");
getSid();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
DefaultHttpClient client = new DefaultHttpClient();
requestPost.addHeader("Cookie", "SID=" + _sid + "; HSID=" + _hsid);
try {
nameValuePairs.add(new BasicNameValuePair("T", _token));
nameValuePairs.add(new BasicNameValuePair("quickadd", "blog.martindoms.com/feed/"));
requestPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(requestPost);
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line + "\n");
}
System.out.println(str.toString());
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}