4

I am requesting to get user friends from an Android App that I am developing. As from Facebook Api V2.0 I know that I should get only user friends that have already logged in through my App. However, although I know certain friends of a user have logged In through my App they do not appear in Facebook Request Response when requesting friends of that user. For example I get back 40 friends rather than 50+.

Has anyone experienced this behavior before? I already deleted app from few users to re-authorized it through login but I haven't see any change in the behavior.

Here is the code I'm using:

new Request(ParseFacebookUtils.getSession(),"me/friends", null, null, new Request.Callback(){

        @Override
        public void onCompleted(Response response) {

            if (response == null){ 
                return;
            }
            else if (response.getError() != null){
                response.getError().getException().printStackTrace();
                return;
            }

            GraphMultiResult result = response.getGraphObjectAs(GraphMultiResult.class);

            List<GraphObject> fbInList = result.getData();

            if (fbInList != null && !fbInList.isEmpty()){

                for (GraphObject user : fbInList) {

                    JSONObject jsonUser = user.getInnerJSONObject(); // The Facebook User
                    System.out.println("name: " + jsonUser.optString("name"));
                }       
            }
        }
    }).executeAsync();
z3n105
  • 1,935
  • 1
  • 15
  • 14
  • Is your app approved by Facebook? Are these people added in your Testers/Developers section on the FB dev console? Is your app open for general public? – Skynet May 06 '15 at 08:36
  • Actually yes, they are added as testers is that an issue? Yes It is open to general public, and no extra permissions are used so I do not need a Login Review. P.S. The App is live for months – z3n105 May 06 '15 at 08:46
  • Okay, `The app is live for months` Their API has changed since April 30, are you aware? – Skynet May 06 '15 at 08:53
  • Yes, this is an extract from https://developers.facebook.com/docs/apps/faq#mandatory : Login Review is mandatory if your app asks for more than public_profile, email and user_friends permissions. Apps that do not request permissions beyond these three permissions do not need to undergo Login Review. After April 30th, we will start removing access to any permissions which have not been approved for use via Login Review. – z3n105 May 06 '15 at 08:54

2 Answers2

4

I've found what was the problem. When I updated to the latest Facebook SDK, Facebook was returning only 25 friends. I needed to use paging or add a limit to my Friend Request. On previous SDK I didn't need to.

Adding limit:

Bundle params = new Bundle();
params.putString("limit", "50"); // Up to 5000?
friendRequest.setParameters(params);

Relevant Stack Overflow Questions:

Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?

newMyFriendsRequest Facebook returns only 25 friends

Useful Facebook link for paging:

https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging

Community
  • 1
  • 1
z3n105
  • 1,935
  • 1
  • 15
  • 14
0

The relevant portion of the doc for you is this

In v2.0 of the API I'm unable to get the full friend list of someone who has logged into my app - is there a way to get the full friend list?

With Graph API v2.0 and above, calls to /me/friends return only the friends who also use your app. These friends must have also granted the user_friends permission. In the cases where you want to let people tag their friends in stories published by your app, you can use the Taggable Friends API. If you want to invite people to your app, we have a number of solutions that depend on the type of app you've built and the platforms you've built for. Please see our question about Inviting Friends for more information.

So along with only friends using your app, they should also have authorized user_friends otherwise you wont get their details. Have you done this?

Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103
  • Yes I've checked in their Facebook App and they have accepted the user_friends permission. I've also asked them to delete the app from Facebook and then reauthorise it but it didn't work as well. – z3n105 May 12 '15 at 11:47
  • Please report a bug as mentioned. Also, what's your FB app-id ? – deesarus May 13 '15 at 03:50
  • Ok I will try to report it. – z3n105 May 13 '15 at 07:01