我想知道如何使用Facebook API for iOS获取朋友的个人资料图片并显示它们。谢谢。
一行解决方案:
https://graph.facebook.com/me/friends?access_token=[oauth_token]&fields=name,id,picture
https://github.com/RIKSOF/three20/tree/development/src/extThree20Facebook
它允许您只需几行代码即可使用所有Graph API功能。
对于寻找此类信息的iOS用户,以下是帮助我解决问题的方法(使用2016年6月版本5的图表):
- (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。