[英]Facebook API for iOS, Getting friends' profile pictures
我想知道如何獲取朋友的個人資料圖片並使用Facebook API for iOS進行顯示
謝謝
一線解決方案:
https://graph.facebook.com/me/friends?access_token=[oauth_token]&fields=name,id,picture
您可以在此端點獲取您的朋友列表: https : //graph.facebook.com/me/friends 。 然后,您可以在此端點獲取朋友的個人資料圖片: https : //graph.facebook.com/ [ profile_id] / picture。
請務必使用此SDK: https : //github.com/facebook/facebook-iphone-sdk
希望這可以幫助!
如果您使用Three20,可以嘗試以下擴展名:
https://github.com/RIKSOF/three20/tree/development/src/extThree20Facebook
它允許您只使用幾行代碼就可以使用所有Graph API功能。
對於尋找這個的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和個人資料照片網址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.