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并尝试获取 token ,但失败了(403禁止)。
是不是方法不对?
我使用了 Apache HttpClient 库。
最佳答案
不再支持使用 SID cookie 进行 Google Reader API 身份验证。支持的认证方式有OAuth和ClientLogin;请参阅http://code.google.com/p/google-reader-api/wiki/Authentication了解更多详情。
关于java - 我在这个 Google Reader 测试代码中错过了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6870871/