Ich versuche, den Benutzer E-Mail und Geburtstag, wenn Benutzer Facebook-Login für meine App verwendet. DieseFacebook Login Benutzer Geburtstag und E-Mail Android
ist, wie ich versuche, es zu tun:
public class MainActivity extends AppCompatActivity {
private LoginButton facebookLoginButton;
private CallbackManager callbackManager;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(getApplication());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_main);
facebookLoginButton = (LoginButton)findViewById(R.id.fb_login_button);
facebookLoginButton.setReadPermissions(Arrays.asList("email","public_profile", "user_birthday"));
facebookLoginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest.newMeRequest(
loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject me, GraphResponse response) {
if (response.getError() != null) {
// handle error
} else {
String email = me.optString("email");
String name = me.optString("name");
String birthday = me.optString("user_birthday");
System.out.println(email);
System.out.println(name);
System.out.println(birthday);
}
}
}).executeAsync();
String userID = loginResult.getAccessToken().getUserId();
String AuthToken = loginResult.getAccessToken().getToken();
System.out.println(userID);
System.out.println(AuthToken);
}
Nur Name, Benutzer-ID und authToken erfolgreich gedruckt, ich bin nicht Wert für Geburtstag und E-Mail bekommen (ich benutze E-Mail für mein Facebook-Konto und zur Verfügung gestellt Geburtstag also sollte es Wert sein).
Bin ich die Erlaubnis falsch?
Sie diesen Link für E-Mail und Geburtstag beziehen. http://stackoverflow.com/questions/32196682/facebook-android-sdk-4-5-0-get-email-address –