我正在使用this代码来获取我的Android应用的fb用户信息。
我的问题是这段代码没有返回所有用户的出生日期,即,如果我通过用户A登录,则返回DOB但是如果我通过用户B登录则不会#39;吨。两个用户都在fb中保存了dob并且还具有隐私设置。
private LoginButton loginButton;
private CallbackManager callbackManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList(
"public_profile", "email", "user_birthday", "user_friends"));
callbackManager = CallbackManager.Factory.create();
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v("LoginActivity", response.toString());
// Application code
String email = object.getString("email");
String birthday = object.getString("birthday"); // 01/31/1980 format
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
// App code
Log.v("LoginActivity", "cancel");
}
@Override
public void onError(FacebookException exception) {
// App code
Log.v("LoginActivity", exception.getCause().toString());
}
});
}
如果有人知道,请分享。
答案 0 :(得分:0)
我认为并非两个用户都在应用中发挥作用,并且user_birthday
未获批准。请查看有关登录审核的文档:https://developers.facebook.com/docs/facebook-login/review