我正在尝试使用代码
检索用户的Facebook好友列表[FBRequestConnection startWithGraphPath:@"/me/friends"
parameters:nil HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id 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);
}
}];
但每当我使用该代码时,它只返回Found:0朋友。我将它放在Viewcontroller中,以便在用户通过Facebook登录后执行。我已经请求了user_friends权限,并且我有一位在应用上注册的朋友。如果它有所不同,该应用程序也在使用Quickblox SDK,所以如果有任何方法可以做到这一点,那就太棒了!
答案 0 :(得分:1)
使用此代码
FBRequest *friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler:^(FBRequestConnection *connection,NSDictionary *result ,NSError *error){
NSLog(@"Friend data :%@",result);
NSArray *friends = [result objectForKey:@"data"];
NSLog(@"friends :%@",friends);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(@"I have a friend named %@ with id %@",friend.name,friend.id);
}
}];
答案 1 :(得分:1)