Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook iOS SDK - get friends list in Graph API v2.4

I am using below code to get Facebook friend that uses app

// Issue a Facebook Graph API request to get your user's friend list
    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"/{friendlist-id}"
                                  parameters:nil
                                  HTTPMethod:@"GET"];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result,
                                          NSError *error) {
        // Handle the result
    }];

But I am getting following response.

{
    data =     (
    );
    summary =     {
        "total_count" = 279;
    };
}

How can I get fbID like we use to get in last api version using FBRequest.

Note I am using latest FB SDK.

Thanks.

like image 715
Muhammad Awais Avatar asked Sep 11 '15 06:09

Muhammad Awais


2 Answers

Its not possible to get FriendList or EmailId of Friends, according to new API version, but if You want show FriendList use TaggableFriend Feature of Facebook.This Taggable API needs Approval from Facebook and this API returns id, Friend name, Profile picture URL.but Id is not FacebookId its Id for Post on wall.This only way to get friends.But if you use me/friends it return total number of friends and friend List of app User. Since you you don't have app user it only showing total Count of Friend.To implement this Feature you login with Admin Account(The Account from which Facebook ID Created)for this you have to implement the paging Concept.

Use this Code Spinnet: "/me/taggable_friends?fields=id,name,picture.type(large).

like image 124
Charmi Avatar answered Sep 19 '22 02:09

Charmi


You have to add permission at login time user_friends

A user access token with user_friends permission is required to view any of that person's friend lists.

you can get only that friends who installed the same apps,

Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven't installed the app.

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                              initWithGraphPath:@"me/friends"
                              parameters:nil
                              HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
like image 44
Kirit Modi Avatar answered Sep 20 '22 02:09

Kirit Modi