Facebook iOS SDK - получить список друзей - PullRequest
32 голосов
/ 10 июля 2011

Используя Facebook iOS SDK, как я могу получить NSArray всех моих друзей и отправить им приглашение в свое приложение? Я специально ищу график пути, чтобы получить всех друзей.

Ответы [ 11 ]

0 голосов
/ 03 июля 2014
-(void)getFBFriends{

    NSDictionary *queryParam =
    [NSDictionary dictionaryWithObjectsAndKeys:@"SELECT uid, sex,name,hometown_location,birthday, pic_square,pic_big FROM user WHERE uid = me()"
     @"OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())", @"q", nil];
    // Make the API request that uses FQL
    [FBRequestConnection startWithGraphPath:@"/fql"
                                 parameters:queryParam
                                 HTTPMethod:@"GET"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error) {
                              if (error) {                                  
                                  NSLog(@"Error: %@", [error localizedDescription]);
                              } else {
                                  NSDictionary *data=result;
                                  //NSLog(@"the returned data of user is %@",data);
                                  NSArray *dataArray=[data objectForKey:@"data"];
                                //dataArray contains first user as self user and your friend list

                              }
                          }];
}
...