Muhammad Awais Muhammad Awais - 5 days ago 6
iOS Question

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.

Answer

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
}];
Comments