Chandrakant
Chandrakant

Reputation: 40

not getting facebook friend list

i am getting null in friends list this is my code

-(void)getFriendList
{
  FBRequest *friendsRequest=[FBRequest requestForMyFriends];


[friendsRequest startWithCompletionHandler:^(FBRequestConnection *connection,NSDictionary* result,NSError *error)
 {
     arrFriendFB = [result objectForKey:@"data"];

     arrFriendFB=[arrFriendFB valueForKey:@"first_name"];
     NSLog(@"friemd=%@",arrFriendFB);

     NSLog(@"friends description :%@",[arrFriendFB description]);

 }];

}

Upvotes: 0

Views: 94

Answers (2)

Rohit
Rohit

Reputation: 577

As new facebook APi doc there is some modification. see some change's mention below

first you need to get access token with "user_friends" permission.

its graph API url:-

https://graph.facebook.com/me/friends?access_token=

For more information follow this link https://developers.facebook.com/docs/facebook-login/permissions/v2.0

Upvotes: 1

Max
Max

Reputation: 2299

use this method to get friend list.

-(void)getFriendList
{
        [FBSession setActiveSession:[self appDelegate].session];
        FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,picture,location"];
        [ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            NSArray *data = [result objectForKey:@"data"];

            //NSLog(@"response : %@",data);

            for (FBGraphObject<FBGraphUser> *friend in data)
            {
                NSLog(@"name : %@",[friend name]);

            }
        }];

}

Upvotes: 0

Related Questions