我的身份验证GReader编辑API有问题。我可以使用HTTPS(https://www.google.com/accounts/ClientLogin)进行身份验证,谷歌会返回三个令牌(SID,LSID,AUTH),但没有HSID。
当我尝试在Cookie中添加一个带有POST数据T = djj72HsnLS8293& quickadd = blog.martindoms.com / feed / without HSID的新订阅源http://www.google.com/reader/api/0/subscription/quickadd?ck=1290452912454&client=scroll时,响应状态码为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();
}
}
答案 0 :(得分:3)
看起来您可能正在使用旧信息作为参考。谷歌现在转而使用auth。
您需要使用getAuth()函数替换getSid()。
然后这一行
requestPost.addHeader("Cookie", "SID=" + _sid + "; HSID=" + _hsid);
现在应该是这个
requestPost.addHeader("Authorization", "GoogleLogin auth=" + _auth);