Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook iOS SDK - get friends list

Using the Facebook iOS SDK, how can I get an NSArray of all my friends and send them an invitation to my app? I am specifically looking for the graph path to get all of the friends.

like image 731
user635064 Avatar asked Jul 10 '11 03:07

user635064


1 Answers

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: %lu friends", (unsigned long)friends.count);     for (NSDictionary<FBGraphUser>* friend in friends) {         NSLog(@"I have a friend named %@ with id %@", friend.name, friend.objectID);     } }]; 
like image 127
Jeff Avatar answered Sep 21 '22 07:09

Jeff