使用ClientLogin验证和Android中使用谷歌阅读器API [英] Authenticating with ClientLogin and using the Google Reader API in Android

查看:230
本文介绍了使用ClientLogin验证和Android中使用谷歌阅读器API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的从我的Andr​​oid应用程序,以谷歌阅读器发表的消息。我使用ClientLogin验证和使用谷歌阅读器API.When我试图发送验证请求它给了一个错误。

I have to post a message from my android application to Google Reader. I'm Authenticating with ClientLogin and using the Google Reader API.When I'm trying to send the authentication request it's giving an error.

HTTP / 1.1 404未找​​到

我觉得客户能够与服务器通信,但服务器无法找到什么requested.I'm给予以下网址
 postURL =htt​​p://www.google.com/reader/api/0/edit为
 HttpPost后=新HttpPost(postURL);

I think the client was able to communicate with the server but the server could not find what was requested.I'm giving the following url postURL = "http://www.google.com/reader/api/0/edit" as HttpPost post = new HttpPost(postURL);.

请告诉我解决解决这个问题。

Please tell me the solution to resolve this issue.

推荐答案

如果你使用的ClientLogin,你可能只需要2种令牌做你需要用unnoficial谷歌阅读器API是什么:

If you're using ClientLogin you will probably need only 2 kinds of tokens to do what you need with the unnoficial Google Reader API:

  • Authentication Token - This is the main authentication token, and you'll need to send this in the header of every GET/POST request to the API, otherwise you'll get an error (not the one you're having, though). You can do a POST to this url for this (I have a full code example ahead): https://www.google.com/accounts/ClientLogin
  • Edit Token - This is the edit token, and you'll need to send this as a form parameter of POST request to any edit APIs (like the http://www.google.com/reader/api/0/edit you've mentioned). You can do a GET to this url for this (I have a code example ahead): http://www.google.com/reader/api/0/token

前往您要举报的404错误,那一定是你有你的网址一个错字。复制我的网址,并尝试一下。双人并排检查,一边。这里是Java code我用这个 - 你可以尝试一下也:

Getting to the 404 error you're reporting, it must be that you have a typo in your url. Copy my url and try it out. Double check it, side by side. Here is the Java code I've used for this - you can try it out also:

    private static final String _AUTHPARAMS = "GoogleLogin auth=";
    private static final String _GOOGLE_LOGIN_URL = "https://www.google.com/accounts/ClientLogin";
    private static final String _READER_BASE_URL = "http://www.google.com/reader/";
    private static final String _API_URL = _READER_BASE_URL + "api/0/";
    private static final String _TOKEN_URL = _API_URL + "token";
    private static final String _USER_INFO_URL = _API_URL + "user-info";
    private static final String _USER_LABEL = "user/-/label/";
    private static final String _TAG_LIST_URL = _API_URL + "tag/list";
    private static final String _EDIT_TAG_URL = _API_URL + "tag/edit";
    private static final String _RENAME_TAG_URL = _API_URL + "rename-tag";
    private static final String _DISABLE_TAG_URL = _API_URL + "disable-tag";
    private static final String _SUBSCRIPTION_URL = _API_URL
    + "subscription/edit";
    private static final String _SUBSCRIPTION_LIST_URL = _API_URL
    + "subscription/list";

    public static String getGoogleAuthKey() throws IOException {

        String _USERNAME = "USER_EMAIL@gmail.com";
        String _PASSWORD = "USER_PASSWORD";

        Document doc = Jsoup
        .connect(_GOOGLE_LOGIN_URL)
        .data("accountType", "GOOGLE", "Email", _USERNAME, "Passwd",
                _PASSWORD, "service", "reader", "source",
                "[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
        .userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
        .timeout(4000).post();

// RETRIEVES THE RESPONSE TEXT inc SID and AUTH. We only want the AUTH
// key.
String _AUTHKEY = doc
        .body()
        .text()
        .substring(doc.body().text().indexOf("Auth="),
                doc.body().text().length());
_AUTHKEY = _AUTHKEY.replace("Auth=", "");
return _AUTHKEY;

}

您可以看到一个code例如用于获取编辑令牌,并在我的答案做一个编辑的此的其他问题

You can see a code example for getting the edit token and doing an edit in my answer to this other question.

请参阅我的答案,如果要这个你想要的文件(非官方的,但良好的结构) - 没有官方文档...

See my answer to this one if you want documentation (unofficial but well structured) - there is no official doc...

在code是基于<一个href=\"http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/\" rel=\"nofollow\">http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/

这篇关于使用ClientLogin验证和Android中使用谷歌阅读器API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆