我希望用户能够使用Facebook注册我的Android应用程序SDK
。为了获取他们的信息,我正在执行GraphRequest
具有“ email
”和“ public_profile
”权限的。根据此页面,应该可以在“ first_name
”和“ last_name
”字段中访问用户的名字和姓氏。但是,当我单击按钮时,出现一条错误消息,指出first_name没有值。JSON
返回的数组如下:
{"name":"First M. Last","id":"1234567890123456"}
我尚未将我的应用提交审核,因为它尚未完成。这可能与这个问题有关吗?
根据官方文件,您用于访问public_profile权限的登录应类似于:
LoginManager.getInstance().logInWithReadPermissions(Login.this, Arrays.asList("public_profile", "email"));
获取个人资料信息:
private void getFbDetails(final AccessToken accessToken) {
GraphRequest request = GraphRequest.newMeRequest(accessToken,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Toast.makeText(Login.this, object.toString(), Toast.LENGTH_LONG).show();
Log.v("FB Details", object.toString());
if (object != null) {
name_fb = object.optString("name");
email_fb = object.optString("email");
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,first_name, last_name, email,link");
request.setParameters(parameters);
request.executeAsync();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句