7

Code i used for fetching the list after doing some search is 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 the permission i get is accessToken : {AccessToken token:ACCESS_TOKEN_REMOVED permissions:[user_friends, basic_info]}

getRecentlyGrantedPermissions : [user_friends, basic_info]

getRecentlyDeniedPermissions : []

and the output of the graph function is -

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

so can anyone please guide me to fetch the friend list of user .

Thanx in advance .

Amit Sharma
  • 91
  • 1
  • 1
  • 5
  • you can use `/me/taggable_friends` check this [answer](http://stackoverflow.com/a/23417628/5891893) – Sally Feb 12 '16 at 13:41

1 Answers1

4

The output is correct, none of your friends authorized your App yet. Since v2.0 of the Graph API you can only get the friends who authorized your App, for privacy reasons: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/friends

More information can be found in this thread: Get ALL User Friends Using Facebook Graph API - Android

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • so is there any way to get permission from friends or it is not possible . and as for graph api i am getting error on **Request** and **Response**. So can u please give me any example how to use graph api in sdk 4.0.1. – Amit Sharma Apr 07 '15 at 12:39
  • you can´t get a list of your friends anymore. click on the last link in my answer, it explains everything. example code for the php sdk is in the docs: https://developers.facebook.com/docs/php/gettingstarted/4.0.0 - not sure what else you need to know, i don´t see any error message in your question. – andyrandy Apr 07 '15 at 12:42
  • thanx. u saved mi time . – Amit Sharma Apr 07 '15 at 12:54
  • Same issue is with me Please post your code to How to get all facebook friend in list? – Nancy thakkar Dec 06 '16 at 10:59
  • what issue? did you open the last link in my answer? did you read the accepted answer over there too? did you read my answer? – andyrandy Dec 06 '16 at 11:00