Get friends list from facebook sdk 4.0.1 in android with api 2.2 chart

Code i used to select a list after performing a search below

GraphRequestBatch batch = new GraphRequestBatch( GraphRequest.newMyFriendsRequest( accessToken, new GraphRequest.GraphJSONArrayCallback() { @Override public void onCompleted( JSONArray jsonArray, GraphResponse response) { // Application code for users friends System.out.println("getFriendsData onCompleted : jsonArray " + jsonArray); System.out.println("getFriendsData onCompleted : response " + response); try { JSONObject jsonObject = response.getJSONObject(); System.out.println("getFriendsData onCompleted : jsonObject " + jsonObject); JSONObject summary = jsonObject.getJSONObject("summary"); System.out.println("getFriendsData onCompleted : summary total_count - " + summary.getString("total_count")); } catch (Exception e) { e.printStackTrace(); } } }) ); batch.addCallback(new GraphRequestBatch.Callback() { @Override public void onBatchCompleted(GraphRequestBatch graphRequests) { // Application code for when the batch finishes } }); batch.executeAsync(); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,link,picture"); 

and I get permission accessToken: {AccessToken token: ACCESS_TOKEN_REMOVED permissions: [user_friends, basic_info]}

getRecentlyGrantedPermissions: [user_friends, basic_info]

getRecentlyDeniedPermissions: []

and the graph function output is

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

so that someone can direct me to get a list of friends of the user.

Thanx in advance.

+7
android facebook facebook-graph-api
source share
1 answer

The result is correct, none of your friends have allowed your application yet. Starting with version 2.0 of the Graph API, you can only get friends who have allowed your application for privacy reasons: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends

More information can be found in this topic: Get ALL user friends using the Facebook API - Android

+4
source share

All Articles