我在好友列表中显示为空这是我的代码
-(void)getFriendList
{
FBRequest *friendsRequest=[FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler:^(FBRequestConnection *connection,NSDictionary* result,NSError *error)
{
arrFriendFB = [result objectForKey:@"data"];
arrFriendFB=[arrFriendFB valueForKey:@"first_name"];
NSLog(@"friemd=%@",arrFriendFB);
NSLog(@"friends description :%@",[arrFriendFB description]);
}];
}
答案 0 :(得分:1)
作为新的Facebook APi doc,有一些修改。看到下面提到的一些变化
首先,您需要获得"user_friends"
权限的访问令牌。
其图表API网址: -
https://graph.facebook.com/me/friends?access_token=
有关更多信息,请点击此链接 https://developers.facebook.com/docs/facebook-login/permissions/v2.0
答案 1 :(得分:0)
使用此方法获取好友列表。
-(void)getFriendList
{
[FBSession setActiveSession:[self appDelegate].session];
FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,picture,location"];
[ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSArray *data = [result objectForKey:@"data"];
//NSLog(@"response : %@",data);
for (FBGraphObject<FBGraphUser> *friend in data)
{
NSLog(@"name : %@",[friend name]);
}
}];
}