0

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]);

 }];

}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • possible duplicate of [iOS Facebook SDK 3.1 Retrieve friend birthday returning null](http://stackoverflow.com/questions/13170850/ios-facebook-sdk-3-1-retrieve-friend-birthday-returning-null) – rishi Jul 07 '14 at 04:24
  • r u using correct "URL types" which u r registered in facebook application..? – Rohit Jul 07 '14 at 04:53
  • i have checked URL tupes is not a issue – Chandrakant Jul 07 '14 at 07:24
  • possible duplicate of [Facebook Graph Api v2.0 me/friends returns empty, or only friends who also use my app](http://stackoverflow.com/questions/23417356/facebook-graph-api-v2-0-me-friends-returns-empty-or-only-friends-who-also-use-m) – Igy Jul 08 '14 at 04:01

2 Answers2

1

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

Rohit
  • 577
  • 1
  • 3
  • 13
0

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]);

            }
        }];

}
Max
  • 2,269
  • 4
  • 24
  • 49