简体   繁体   中英

how to get facebook friend list with emails through new graph api, v2.5?

I am trying to fetch the friend list using the code below

GraphRequest request = GraphRequest.newMyFriendsRequest(
                token,
                new GraphRequest.GraphJSONArrayCallback() {
                    @Override
                    public void onCompleted(JSONArray array, GraphResponse response) {
                        // Insert your code here
                    }
                });
        request.executeAsync();
    }

The response returned after code execution is

{Response:  responseCode: 200, graphObject: {"data":[],"summary":{"total_count":461}}, error: null}

Persmission to access friends and public profile is granted on login time. How can i fetch my friend list and their public emails/ facebook emails?

You'll only receive the friends whcih are also using your app, see

/me/friends returns the user's friends who are also using your app In v2.0, the friends API endpoint returns the list of a person's friends who are also using your app. In v1.0, the response included all of a person's friends.

And, no , there is no workaround in case you wanted to ask.

You can recive your friends list using graph-api call

/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/me/friends",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();

But the limitation is

  1. api required access token with user_friends permission
  2. only return friends who are also given access permission to the same app you are using

. https://developers.facebook.com/docs/graph-api/reference/v2.5/user/friends

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM