Facebook iOS SDK - get friends list

后端 未结 11 1446
猫巷女王i
猫巷女王i 2020-12-07 12:41

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 ge

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 12:59

    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* friend in friends) {
            NSLog(@"I have a friend named %@ with id %@", friend.name, friend.objectID);
        }
    }];
    

提交回复
热议问题