How to get user email on GraphRequest.newMeRequest

后端 未结 1 950
说谎
说谎 2020-12-30 13:26

I have a Facebook login option in my Android app and I am trying to get the user\'s email unsuccessfully. After the user is logged in, and added to the Parse.com User table

相关标签:
1条回答
  • 2020-12-30 14:13

    I guess this is related to a change in the Graph API v2.4 which makes it necessary that you specify every field you want to have returned from the Graph API.

    Have a look at my answer at

    • Facebook only returning name and id of user

    regarding this

    Concerning your actual problem, see

    • https://developers.facebook.com/docs/android/graph#userdata

    for an example on how to specify the fields for a GraphRequest

    GraphRequest request = GraphRequest.newMeRequest(
            accessToken,
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(
                       JSONObject object,
                       GraphResponse response) {
                    // Application code
                }
            });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email");
    request.setParameters(parameters);
    request.executeAsync();
    
    0 讨论(0)
提交回复
热议问题