Search code examples
facebook-graph-apirandomcountuserid

How can I count the amount of Facebook friends in iOS sdk?


I'm trying to figure out how to get a random userID from my friends.

is there a way to do it with "friendPickerController" ? the only "count" method I've found is in the selection, which dosen't help.


Solution

  • You can get the total friend count using following method

    FBRequest* friendsRequest = [FBRequest requestForMyFriends];
    [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                      NSDictionary* result,
                                      NSError *error) {
        NSArray* friends = [result objectForKey:@"data"];
    
    
        NSLOG(@"Total Friend :%@",friends.count);
    }];