我正在制作一个利用用户 Facebook 好友列表的应用程序。我的解析后端有一个名为 fbFriendsList
的数组类型列。环顾四周后,到目前为止我有这个:
//my permission array
NSArray *permissionsArray = @[ @"user_about_me",@"email", @"user_friends"];
//My fb request for friends after verifying that user is logging in the first time
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSArray *friendObjects = [result objectForKey:@"data"];
//fbFriendIds is a Mutable array i have declared
fbFriendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
// Create a list of friends' Facebook IDs
for (NSDictionary *friendObject in friendObjects) {
[fbFriendIds addObject:[friendObject objectForKey:@"id"]];
}
}
}];
这样做后,我没有收到列表中的任何 friend 。所以我尝试了这个:
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
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);
}
}];
但我还是没有得到 friend 。稍后在函数中,我将数组保存到 PFUser
像这样
user[@"fbFriendsList"] = friends;
[user saveInBackground];
但这会返回Found:0
。为什么这些方法不能检索好友列表?我怎样才能做到这一点并将其保存到我的解析后端?
最佳答案
自 2014 年 4 月起,您只能获得那些也授权您的应用程序的用户,请查看变更日志:https://developers.facebook.com/docs/apps/changelog
未授权您的应用程序的用户不可能知道您是否存储了他们的数据,因此如果您考虑隐私,这是有道理的。
现在获得所有 friend 的唯一方法是使用 invitable_friends用于邀请用户使用您的应用程序和 taggable_friends用于标记用户。但就您而言,没有办法获得所有这些。
关于ios - 如何检索 Facebook 好友列表并保存以供解析?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26700052/