android - 图请求错误 500

标签 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: An unknown error has occurred.}}

更新 发现限制小于等于 33 它可以正常工作

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

对于另一个页面的提要,限制必须小于 7 才能正常工作

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

问题: 现在对页面提要的图形 API 请求的限制规则是什么?

最佳答案

Facebook Graph API 也有 Debug模式。您需要在 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";

或者

在您的 Bundle 中添加一个额外的参数“debug”“all”

并检查您收到的调试信息

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

关于android - 图请求错误 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42421728/

相关文章:

android - AppEventsLogger.deactivateApp(Context 上下文) 已弃用

java - 注销 Facebook Android SDK

android - 在 adb shell 中查找最后修改的文件

android - 使用 Android 应用程序和网络服务处理 Facebook token 过期

java - 如何从android中的Edittext连续获取值

php - Facebook 图形 API 和使用新图形 SDK (PHP) 的删除后回调

python - Facebook Graph 的空响应

node.js - 从 NodeJs 发布到 Facebook 用户源

Android:整个 ListView 在焦点上改变颜色,而不仅仅是 ListView 子项

android - 即使使用 android :inputType ="textPassword",EditTextPreference 也不会屏蔽密码