How to Get friend list of facebook login user using FacebookSDK v3.21

707 views Asked by At

i try following code to get list of friend, but i am getting those friend who using app, i need to get full list of friend. code is given below.

  [FBRequestConnection startWithGraphPath:@"/me/friends"
                             parameters:nil
                             HTTPMethod:@"GET"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSLog(@"My Friend listed : is %@",result);
                          /* handle the result */
                      }];
4

There are 4 answers

0
andyrandy On

https://developers.facebook.com/docs/apps/faq#invite_to_app

Request dialog and invitable_friends are out of the question, as you are talking about an iOS App (not a Game on Canvas). So according to the docs, this is the best option: https://developers.facebook.com/docs/ios/share/#message-dialog

1
Urmi On

Facebook API call now only returns friends who have used the app. so, you can't fetch your whole friend list, only friends who are also using the app.

Check this link for more info

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

1
Tapas Pal On

As you got, /me/friends returns friends who are using the app.

From the Facebook doc references

  1. https://developers.facebook.com/docs/games/invitable-friends/v2.0
  2. https://developers.facebook.com/docs/games/requests/v2.0

use @"/me/invitable_friends" instead of @"/me/friends"

UPDATED

As of April 30th'2014, apps can only get the list of friends who are also using the app, and you have to request the user_friends permission as you are getting now. For those users who have never logged in to your app before April 30th'2014 will get an app_scoped_id instead of their real facebook id.

0
Raju On

With Facebook SDK 3.0 you can do this:

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                  NSDictionary* result,
                                  NSError *error) {
    NSArray* friends = [result objectForKey:@"data"];
    NSLog(@"Found: %i friends", friends.count);
    for (NSDictionary<FBGraphUser>* friend in friends) {
        NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
    }
}];