-1

I am using this for fb login :

LoginManager.getInstance().logInWithReadPermissions(FindFriendActivity.this, Arrays.asList("public_profile", "user_friends", "email"));

FacebookSdk.sdkInitialize(this.getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
        LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>()
                {
                    @Override
                    public void onSuccess(LoginResult loginResult)
                    {
                        Log.d("Success", "Login");
                        GraphRequest graphRequestAsyncTask = new GraphRequest(
                                loginResult.getAccessToken(), "/me/friends", null, HttpMethod.GET, new GraphRequest.Callback()
                        {
                            public void onCompleted(GraphResponse response)
                            { 
                               JSONArray rawName = response.getJSONObject().getJSONArray("data");
                            }
                        }
                        );
                        Bundle parameters = new Bundle();
                        parameters.putString("fields", "id,name,picture,email");
                        graphRequestAsyncTask.setParameters(parameters);
                        graphRequestAsyncTask.executeAsync();
                    }

                    @Override
                    public void onCancel()
                    {
                        Utilities.ShowToast(mContext, "Facebook Login cancel");
                    }

                    @Override
                    public void onError(FacebookException exception)
                    {
                        Utilities.ShowToast(mContext, exception.getMessage());
                    }
                }
        );


@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }

Manifest :

<meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>

 <uses-permission android:name="android.permission.INTERNET"/>

Response :

{Response:  responseCode: 200, graphObject: {"data":[{"id":"10210065337685894","name":"abc","picture":{"data":{"is_silhouette":false,"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xlp1\/v\/t1.0-1\/p50x50\/13501928_10209152837153951_2277267834804945940_n.jpg?oh=1fdb4269d216309e39afe4fc9460011f&oe"}}},{"id":"1249098285123628","name":"xyz","picture":{"data":{"is_silhouette":false,"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xfp1\/v\/t1.0-1\/p50x50\/13501829_1199623916737732_4120441565269954276_n.jpg?oh=d030d56a261964d37ffe287887122fba&oe=58ACFF22&__gda__=1486855096_"}}},{"id":"901840776615466","name":"pqr","picture":{"data":{"is_silhouette":false,"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xaf1\/v\/t1.0-1\/c0.0.50.50\/p50x50\/48142_460427077423507_21768463_n.jpg?oh=3801d55da3bca5a30546e627f3f068f9&oe"}}}],"paging":{"cursors":{"before":"QVFIUkdhcmpmOXdFVVRDSlppQjMxR0FEc2NTNW82bnQzaUZAFUmhmRUtqX0JaV25vV1pvalFoVm11clpvQm9tOXFsRkEZD","after":"QVFIUnZAsN0RReThOMkEyaUZAYQUJuVFRma0JiMU4wQXVGaTNTd2xORjlFdmpUR0FSOEtPbEw1WjMtRWhOMF82czZAWWVNWMktYMlV6Tzk4ZAGEwOUdNRllveGdB"}},"summary":{"total_count":6}}, error: null}
Apurva Kolapkar
  • 1,270
  • 2
  • 16
  • 32
  • Possible duplicate of [How can I get facebook friends list email addresses?](http://stackoverflow.com/questions/8797874/how-can-i-get-facebook-friends-list-email-addresses) – Beloo Oct 14 '16 at 12:54
  • So i think the only issue left is that your friends haven't grant `email` permission to your app. Have you checked this? You can't obtain all friend's emails – Beloo Oct 14 '16 at 12:55

1 Answers1

2

If you request the email permission it is not guaranteed you will get an email address. For example, if someone signed up for Facebook with a phone number instead of an email address, the email field may be empty.

Read More here

Cliff
  • 682
  • 8
  • 30
  • In that case email address should return empty. And for my friends there are email address available still not in response. – Apurva Kolapkar Oct 14 '16 at 08:44
  • @Apurvak also your friends should set theirs emails as public property (via facebook settings) or that emails still haven't been accessible – Beloo Oct 14 '16 at 08:49
  • @Beloo Thanks, But Its still not there in response after changing email access to public. – Apurva Kolapkar Oct 14 '16 at 10:38