使用Facebook Api生日返回null在android中

时间:2017-04-08 05:43:54

标签: android facebook user-interface facebook-graph-api interface

在Android App中整合Facebook Api。我正在使用Facebook sdk:4.21.0,但是当GraphRequest Call生日不在Json Response中返回时。请让我知道什么是错的。我也通过向公众许可用户的出生日期进行测试。

GraphRequest request = GraphRequest.newMeRequest(
                AccessToken.getCurrentAccessToken(),
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        LogUtils.logE(TAG, "JsonResponse: " + object);

                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "id,name,birthday,picture.type(large)");
        request.setParameters(parameters);
        request.executeAsync();

1 个答案:

答案 0 :(得分:1)

user_birthday方法

中添加logInWithReadPermissions()参数
 LoginManager.getInstance().logInWithReadPermissions(MyProfil‌​eActivity.this, Collections.singletonList("public_profile", "email", "user_birthday", "user_friends"));

loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList(
                "public_profile", "email", "user_birthday", "user_friends"));