2011-04-20 28 views
2

我必須從我的Android應用程序向Google閱讀器發送消息。我使用ClientLogin進行身份驗證並使用Google Reader API。當我嘗試發送身份驗證請求時,它提供了一個錯誤。使用ClientLogin進行身份驗證並在Android中使用Google Reader API

HTTP/1.1 404未找到

我認爲客戶端能夠與服務器進行通信,但服務器無法找到什麼requested.I'm給予以下網址 postURL =「HTTP: //www.google.com/reader/api/0/edit「爲 HttpPost post = new HttpPost(postURL);.

請告訴我解決此問題的解決方案。

回答

1

如果您使用的ClientLogin你可能只需要2種令牌做你需要與unnoficial谷歌閱讀器API是什麼:


前往您所報告 404錯誤,那一定是你有一個錯字你的網址。複製我的網址並嘗試一下。仔細檢查,並排。下面是我用這個Java代碼 - 你可以試一下也:

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 = "[email protected]"; 
     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; 

}

你可以看到越來越編輯令牌,並在我的答案做一個編輯的代碼示例this other question

見我的回答對this one如果你想文檔(非官方的,但良好的結構) - 沒有官方文檔...

的代碼是基於http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/

相關問題