繁体   English   中英

通过Parse.com iOS获取Facebook朋友

[英]Get Facebook friends with Parse.com iOS

以下是我的代码,用于为用户登录获取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_friends Facebook权限仅将已批准user_friends权限到应用程序的用户的好友返回。

为了使一个人出现在一个人的朋友列表中,两个人都必须决定与您的应用共享他们的朋友列表,并且在登录时未禁用该权限。 同样,必须在登录过程中要求两个朋友都提供user_friends。 1个

因此,除非您的某些Facebook朋友已经批准了对同一应用程序的许可,否则您将获得一个空朋友的列表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM