Get ALL User Friends Using Facebook Graph API - Android [duplicate]
Asked Answered
D

1

51

I'm trying to get all friends, of a user that logged into my application.

I can't use this API [friends]:

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

Because this API only returns any friends who have used the app making the request.

So I found this API [friendlist]:

https://developers.facebook.com/docs/graph-api/reference/v2.0/friendlist

Followed this answer, I got the friendlist list.

But I'm getting empty list when trying to get friendlist's members:

new Request(
            session,
            "/2692926356774/members",
            null,
            HttpMethod.GET,
            new Request.Callback()
            {
                public void onCompleted(Response response)
                {
                    /* handle the result */
                    Log.e(LOG_TAG,"Members: " + response.toString());
                }
            }
    ).executeAsync();

2692926356774 is my Acquaintances list id, I tried few other id's with the same result.

Deuce answered 25/5, 2014 at 0:2 Comment(7)
You should read developers.facebook.com/docs/graph-api/reference/v2.0/… . There is a big warning at the top which say it doesn't exists v2.0. It is not possible to get all friends in v2.0Seaweed
The warning talked about API v1. Anyway, what is the alternative?Deuce
It depends on what you want to do. We added taggable_friends, invitable_friends and social context APIs. So if you want to do what those API makes available then you should use them. If you want to do something else that requires all friends that is not possibleSeaweed
Sign in petition for API change: change.org/petitions/…Alike
@Seaweed If /{friend-list-id}/members won't return any data, why is it still available, why isn't this thing clearly specified? People will waste a lot of time trying to make it work.Vanadium
@ApetroaeiAndrei: I don't know. Please file a documentation bug so we can remove itSeaweed
same error.. :( it returns only app users.Klaus
D
85

In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app.

In addition, in v2.0, you must request the user_friends permission from each user. user_friends is no longer included by default in every login. Each user must grant the user_friends permission in order to appear in the response to /me/friends. See the Facebook upgrade guide for more detailed information, or review the summary below.

The /me/friendlists endpoint and user_friendlists permission are not what you're after. This endpoint does not return the users friends - its lets you access the lists a person has made to organize their friends. It does not return the friends in each of these lists. This API and permission is useful to allow you to render a custom privacy selector when giving people the opportunity to publish back to Facebook.

If you want to access a list of non-app-using friends, there are two options:

  1. If you want to let your people tag their friends in stories that they publish to Facebook using your App, you can use the /me/taggable_friends API. Use of this endpoint requires review by Facebook and should only be used for the case where you're rendering a list of friends in order to let the user tag them in a post.

  2. If your App is a Game AND your Game supports Facebook Canvas, you can use the /me/invitable_friends endpoint in order to render a custom invite dialog, then pass the tokens returned by this API to the standard Requests Dialog.

In other cases, apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission).

For apps wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the new Message Dialog on iOS and Android.

Distaff answered 29/5, 2014 at 5:43 Comment(11)
then any other option for getting whole friends list of user....Sporogonium
I want to get all my facebook friends videos using graph API v2.0 ? I am able to accomplish this using v1.0Mon
I am using Message Dialog for invite friends. I got transaction id in return after successfully transaction but message or text not posting in friends profile or wall! I am using v2.2 Any ida?Biquadratic
developers.facebook.com/docs/graph-api/reference/v2.3/…Botanist
As of 2.0, this is impossible via the Public API. If you really need this, your only solution is to obtain the user-s Master Token like FLT does. Retrieving the master token is not difficult to implement, but this one requires the user's login credentials. Usually, nobody will trust software that uses your Facebook Password. Also, retrieving the master token will register a login session from your server, so users will see "Your account was accessed from..." messages and most likely their account will become locked and they will need to Save browser. This is against Facebook TOS!!!!!Brewis
thanks i added permission parameter : user_friends but fb not providing key to add for request ..by using key : friendlists it works ..thanks stackoverflow :)Grouty
For some reason I cannot get user_friendlists permission to be prompted to existing user to accept or deny. linkAlkalinity
Is it possible on 2.5 version or latest version?Altercation
How you resolve that issue Please post your code or api link?Klaus
@ПетърПетров What is this "master token" of which you speak? What is FLT?Bevatron
The real access token. The one that can only be obtained after a real, full login with username/password and a security code/sms/whatnot. Now, of course, undocumented. you will need to login as the user itself completely impersonating him. This is strictly forbidden by facebook's API and terms, but Friends List Tracker website did exactly that. This can, of course, steal user's passwords so it's insecure.Brewis

© 2022 - 2024 — McMap. All rights reserved.