标签:editing google-reader authentication api java
身份验证GReader编辑API遇到问题.我可以进行HTTPS(https://www.google.com/accounts/ClientLogin)进行身份验证,并且google返回三个令牌(SID,LSID,AUTH),但没有HSID.
当我尝试使用POST数据T = djj72HsnLS8293& quickadd = blog.martindoms.com / feed /添加新的Feed http://www.google.com/reader/api/0/subscription/quickadd?ck=1290452912454&client=scroll时,在Cookie中没有HSID时,响应状态代码为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();
}
}
解决方法:
看起来您可能正在使用旧信息作为参考. Google现已切换为使用身份验证.
您需要将getSid()替换为getAuth()函数.
然后这条线
requestPost.addHeader("Cookie", "SID=" + _sid + "; HSID=" + _hsid);
现在应该是这个
requestPost.addHeader("Authorization", "GoogleLogin auth=" + _auth);
标签:editing,google-reader,authentication,api,java 来源: https://codeday.me/bug/20191209/2095356.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。