2017-02-23 80 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