下面是我为登录用户获取 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/