适用于iOS的Facebook API,获取朋友的个人资料照片

我想知道如何获取朋友的个人资料图片并使用Facebook API for iOS进行显示

谢谢

您可以在此端点获取您的朋友列表: https : //graph.facebook.com/me/friends 。 然后,您可以在此端点获取朋友的个人资料图片: https : //graph.facebook.com/ [ profile_id] / picture。

请务必使用此SDK: https : //github.com/facebook/facebook-iphone-sdk

希望这可以帮助!

一线解决方案:

https://graph.facebook.com/me/friends?access_token=[oauth_token]&fields=name,id,picture 

如果你使用Three20,你可以尝试这个扩展:

https://github.com/RIKSOF/three20/tree/development/src/extThree20Facebook

它允许您只使用几行代码就可以使用所有Graph APIfunction。

对于寻找这个的iOS用户来说,这是帮助我的东西(使用图表的第5版,2016年6月):

 - (void)getUsersFaceBookFriends { NSDictionary *params = @{@"fields": @"name, id, picture"}; FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/friends" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { if (!error) { NSArray * friendList = [result objectForKey:@"data"]; for (NSDictionary * friend in friendList) { NSLog(@"Friend id: %@", friend[@"id"]); NSLog(@"Friend name: %@", friend[@"name"]); NSLog(@"Friend picture: %@", friend[@"picture"]); } } }]; } 

此代码将获取用户的Facebook好友,他们也使用该应用程序,以及他们的名称,ID和个人资料照片url。