user3164248
user3164248

Reputation: 155

How to get a facebook users friends and profile picture of friends using graph api v2.0?

Facebook have updated their graph api to v2.0 recently (april 30, 2014). What is the standard api call to get facebook friends and their profile pictures now? (me/friends does not work as I want all of the friends not friends who use the app)

Upvotes: 1

Views: 3729

Answers (3)

John Lanzivision
John Lanzivision

Reputation: 453

Way late everybody, but this info isn't out there.

Here's how you get the taggable_friends Facebook profile pic (large too!)

 [FBRequestConnection startWithGraphPath:@"/me/taggable_friends?fields=id,name,picture.type(large)"
                             parameters:nil
                             HTTPMethod:@"GET"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSArray* friends = [result objectForKey:@"data"];
                          NSLog(@"Found: %i friends", friends.count);
                         for (NSDictionary<FBGraphUser>* friend in friends) {



                             NSDictionary *pictureData = [[friend objectForKey:@"picture"] objectForKey:@"data"];

                             NSString *imageUrl = [pictureData objectForKey:@"url"];

                             NSLog(@"Facebook profile image url %@", imageUrl);



                          }




                      }];

This retrieves all Facebook friends, and parses each friend for the imageURL. You can parse the 'friend' node for the taggable link (only works if you tag a friend from the app) and their username.

Upvotes: 2

Emil Banca
Emil Banca

Reputation: 36

    Next code will provide the taggable_friends with Url pictures at wanted sizes.

Session session = Session.getActiveSession();
    Bundle params = new Bundle();
    params.putString("fields", "picture.width(" + size.x + ").height(" + size.y + ")");
    Request request = new Request(session, "/me/taggable_friends", params, HttpMethod.GET, new Request.Callback() {
        public void onCompleted(Response response) {


        }
    });
    Request.executeBatchAsync(request);

Upvotes: 1

Simon Cross
Simon Cross

Reputation: 13345

In v2.0 of the Graph API, /me/friends includes only the user's friends who have also logged into the app.

To get the non-app using friends in the case of tagging and inviting, you can use the new /me/taggable_friends and /me/invitable_friends endpoints.

More details here: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app and here: Get facebook friends with Graph API v.2.0

Upvotes: 3

Related Questions