我正在使用最新版本的 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 和 email 权限,因此,我希望根据 API 查看电子邮件、家乡和其他信息,就像 Graph 对象本身一样。有没有人见过这样的事情?
提前致谢
最佳答案
您获得了请求对象,但在 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
关于android - Facebook Android SDK 未返回所有个人资料信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35833955/