2017-02-23 79 views
8

我的應用程序使用facebook登錄按鈕的facebook-android-sdk。 這是工作,直到最後的日子,現在的圖形要求在頁面的飼料圖形請求錯誤500

Bundle parameters = new Bundle(); 
parameters.putString("fields", "id,icon,created_time,name,caption,description,message,link,full_picture,shares"); 
parameters.putString("limit", "50"); 
parameters.putString("locale", mLocale); 
String pathPosts = path + "/posts"; 
GraphRequest request = new GraphRequest(
     AccessToken.getCurrentAccessToken(), pathPosts, parameters, HttpMethod.GET, 
     new GraphRequest.Callback() { 
      @Override 
      public void onCompleted(
       GraphResponse response) { 
       mResponse = response; 
       } 
     }); 
request.executeAndWait(); 

我得到的OAuthException錯誤

{Response: responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: 1, errorType: OAuthException, errorMessage: An unknown error has occurred.}}

UPDATE 發現,限比33,等於降低它無誤地運行

parameters.putString("limit", "33"); 

對於其他頁面的Feed,限制必須低於等於7沒有錯誤

工作
parameters.putString("limit", "7"); 

問:現在 什麼是在頁面的飼料的圖形API請求的限制規則?

+0

檢查,如果您有任何錯誤的構造函數,或忘記包含權限。也很有可能登錄狀態或訪問令牌已過期,已被撤銷或無效。獲取新的訪問令牌。 – PN10

+0

您使用的是什麼版本的GraphAPI? –

+0

@ PN10令牌是有效的,適用於應用程序和Graph Api Explorer。我的問題是,當限制變量值更大時,我會收到錯誤。 – GPack

回答

3

Facebook Graph API還有一個調試模式。您需要在REST API中傳遞一個額外的參數debug = all。如果有任何問題,它會在響應JSON時給你提出問題的原因。

報價Facebook的文檔 -

When Debug Mode is enabled, Graph API response may contain additional fields that explain potential issues with the request. To enable debug mode, use the debug query string parameter. For example:

GET graph.facebook.com /v2.3/me/friends access_token=...& debug=all

在代碼中,嘗試改變這個

String pathPosts = path + "/posts"; 

這個

String pathPosts = path + "/posts&debug=all"; 

或者

添加和一個額外的參數「去錯誤」,‘所有’在你的包

和檢查什麼調試消息你有

有關錯誤處理和調試圖形API的更多信息,請參見這裏 - https://developers.facebook.com/docs/graph-api/using-graph-api/#errors