ios - 使用 Parse.com iOS 获取 Facebook 好友

标签 ios facebook parse-platform

下面是我为登录用户获取 facebook 好友的代码。

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/friends" parameters:@{@"fields": @"email, name, first_name, last_name, user_friends, id"}];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
     {
         if (!error)
         {
             NSArray *friendObjects = [result objectForKey:@"data"];
             NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
             // Create a list of friends' Facebook IDs
             for (NSDictionary *friendObject in friendObjects) {
                 [friendIds addObject:[friendObject objectForKey:@"id"]];
             }

             // Construct a PFUser query that will find friends whose facebook ids
             // are contained in the current user's friend list.
             PFQuery *friendQuery = [PFUser query];
             [friendQuery whereKey:@"fbId" containedIn:friendIds];
             [friendQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
                 if (error) {

                 } else {
                     self.friendUsers = objects; // self.friendUsers in array
                     [self.tableView reloadData];
                 }
             }];

         }
     }];

我没有得到任何结果,我不确定为什么我遵循这里的步骤 https://parse.com/questions/how-can-i-find-parse-users-that-are-facebook-friends-with-the-current-user

请帮忙

最佳答案

user_friends Facebook 权限仅返回已批准应用程序 user_friends 权限的用户的好友。

In order for a person to show up in one person's friend list, both people must have decided to share their list of friends with your app and not disabled that permission during login. Also both friends must have been asked for user_friends during the login process. 1

因此,除非您的一些 Facebook 好友已经批准了对同一应用的权限,否则您将得到一个空的好友列表。

关于ios - 使用 Parse.com iOS 获取 Facebook 好友,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35456578/

相关文章:

java - 自定义 ParseQueryAdapter 未填充 Android ListView

iphone - 如何判断 UserLocation 是在 MKPolygonview 中还是在 iOS MKMapView 中的特定区域内?

ios - 当我尝试获取联系人的电话号码时出现错误 "fatal error: unexpectedly found nil while unwrapping an Optional value"

ios - Facebook 应用程序未授权,使用 Facebook SDK 从我的 iOS 应用程序调用

ios - 如何通过点击 Swift 中的按钮来打开 Facebook 和 Instagram 应用程序

facebook - 使用适用于 iOS 的 Facebook 和 Twitter SDK 注册

ios - Facebook 登录按钮对齐 iOS

ios - 围绕一个点旋转的一步仿射变换?

ios - 类型 'Int' 没有下标成员

swift - Parse - 使用云代码发送推送通知 (Swift)