java - 我在这个 Google Reader 测试代码中错过了什么?

标签 java httpclient 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并尝试获取 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/

相关文章:

java - 创建从 Android 应用程序的 Assets 文件夹内部到其存储的符号链接(symbolic link)

java - 重画问题

java - 使用 REST 和 HttpClient 访问 Facebook API

java - Struts2 框架中的 NoClassDefFoundError

rss - 我可以获得 RSS 阅读量的统计数据吗?

google-reader - 如果我在没有 token 的情况下使用他们的功能,Google 会阻止我的访问吗?

JavaFx 自定义按钮的外观

Java GZip 一个对象并使用 MappedByteBuffer 对其进行序列化

c# - 多个带有代理的 HttpClients,试图达到最大下载速度