我在这个 Google Reader 测试代码中错过了什么?
public void getToken() {
BasicClientCookie cookie = new BasicClientCookie("SID", sid);
cookie.setPath("/");
cookie.setDomain(".google.com");
CookieStore store = new BasicCookieStore();
store.addCookie(cookie);
String url = "http://www.google.com/reader/api/0/token";
HttpClient httpclient = new DefaultHttpClient();
HttpGet req = new HttpGet(url);
((DefaultHttpClient)httpclient).setCookieStore(store);
try {
token = httpclient.execute(req, Misc.StringRespHandler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
我正在测试连接到 Google 阅读器。
获取SID成功。 所以我制作了一个SID cookie并尝试获取令牌,但失败了(403禁止)。
是不是方法不对呢?
我使用 Apache HttpClient 库。
public void getToken() {
BasicClientCookie cookie = new BasicClientCookie("SID", sid);
cookie.setPath("/");
cookie.setDomain(".google.com");
CookieStore store = new BasicCookieStore();
store.addCookie(cookie);
String url = "http://www.google.com/reader/api/0/token";
HttpClient httpclient = new DefaultHttpClient();
HttpGet req = new HttpGet(url);
((DefaultHttpClient)httpclient).setCookieStore(store);
try {
token = httpclient.execute(req, Misc.StringRespHandler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
I'm testing to connect to Google Reader.
Getting SID was successful.
So I made a SID cookie and tried to get a token, but it failed (403 forbidden).
Is it a wrong way?
I used Apache HttpClient library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不再支持使用 SID cookie 进行 Google Reader API 身份验证。支持的认证方式有OAuth和ClientLogin;请参阅 http://code.google.com/p/google-reader- api/wiki/Authentication 了解更多详细信息。
Using a SID cookie for Google Reader API authentication is no longer supported. Supported authentication methods are OAuth and ClientLogin; see http://code.google.com/p/google-reader-api/wiki/Authentication for more details.