iOS Facebook SDK – 获取与App连接的朋友列表

前端之家收集整理的这篇文章主要介绍了iOS Facebook SDK – 获取与App连接的朋友列表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试获取所有我的Facebook朋友的列表,谁正在使用应用程序我得到所有的朋友的列表,但是如何过滤所有使用该应用程序的朋友?
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
    [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,NSDictionary* result,NSError *error) {
        NSArray* friends = [result objectForKey:@"data"];
        NSLog(@"Found: %i friends",friends.count);
        for (NSDictionary<FBGraphUser>* friend in friends) {
            NSLog(@"I have a friend named %@ with id %@",friend.name,friend.id);

        }
        NSArray *friendIDs = [friends collect:^id(NSDictionary<FBGraphUser>* friend) {
            return friend.id;
        }];

    }];

谢谢.

解决方法

这是iOS5如何运作的方式
FBRequest* friendsRequest = [FBRequest requestWithGraPHPath:@"me/friends?fields=installed" parameters:nil HTTPMethod:@"GET"];
        [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,NSError *error) {
            NSArray* friends = [result objectForKey:@"data"];
            NSLog(@"Found: %i friends",friends.count);
            for (NSDictionary<FBGraphUser>* friend in friends) {
                NSLog(@"I have a friend named %@ with id %@",friend.id);

            }
            NSArray *friendIDs = [friends collect:^id(NSDictionary<FBGraphUser>* friend) {
                return friend.id;
            }];

     }];

猜你在找的iOS相关文章