Facebook Android sdk没有返回所有个人资料信息

时间:2016-03-06 23:33:14

标签: android facebook facebook-graph-api

我使用最新版本的Facebook Android SDK,使用他们自己的教程,使用Facebook登录按钮构建应用程序。登录后,我执行了对GraphAPI的调用(如此处https://developers.facebook.com/docs/graph-api/reference/user所示)但是,我收到的唯一内容是帐户名和ID。 我还尝试使用以下代码获取用户个人资料信息:

GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response) {
                            // My code
                        }
                    });

            request.executeAsync();

但答案总是一样的:只有用户名和ID。我错过了什么吗?我要求 public_profile 电子邮件权限,因此,我希望将信息视为电子邮件,家乡和其他内容,就像Graph对象本身一样,根据API。有没有人见过这样的东西?

提前致谢

1 个答案:

答案 0 :(得分:3)

你有你的请求对象,但在executeAsync()之前执行此操作:

Bundle parameters = new Bundle();
parameters.putString("fields", "id, first_name, last_name, email,gender, birthday, location");
request.setParameters(parameters);
request.executeAsync();

我在这里找到了这个:Facebook Android SDK 4.5.0 get email address所以尽量提高你的Google技能:D

相关问题