图形请求错误500

时间:2017-02-23 16:51:35

标签: android facebook-graph-api facebook-android-sdk

我的应用使用facebook-android-sdk的Facebook登录按钮。 它一直工作到最后几天,现在是关于页面提要的图表请求

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:发生了未知错误。}}

更新 发现如果限制低于33,则可以正常工作

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

对于其他页面的Feed,限制必须低于7才能正常工作

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

问题: 什么是图表api请求页面Feed的限制规则?

1 个答案:

答案 0 :(得分:3)

Facebook Graph API也有一个调试模式。您需要在REST API中传递一个额外的参数 debug = all 。如果有任何问题,它会在响应JSON中给出问题的原因。

引用Facebook文档 -

  

启用调试模式后,Graph API响应可能包含其他内容   解释请求潜在问题的字段。启用调试   模式,使用调试查询字符串参数。例如:

     

获取graph.facebook.com /v2.3/me/friends       =的access_token ...&安培;       调试=所有

在您的代码中,尝试更改此

userInfo

到这个

String pathPosts = path + "/posts";

添加一个额外的参数" debug" "所有"在你的Bundle

并检查您收到的调试信息

有关处理错误和调试Graph API的详细信息,请参阅此处 - https://developers.facebook.com/docs/graph-api/using-graph-api/#errors

相关问题