【问题标题】:Facebook API for iOS, Getting friends' profile picturesFacebook API for iOS, 获取好友头像
【发布时间】:2011-01-25 06:08:22
【问题描述】:

我想知道如何获取朋友的头像并使用 iOS 版 Facebook API 显示它们

谢谢

【问题讨论】:

    标签: facebook ios


    【解决方案1】:

    一线解决方案:

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

    【讨论】:

    • 好东西。一个班轮是我们的朋友。
    • 如何从graph api获取访问令牌?
    【解决方案2】:

    您可以在此端点获得好友列表:https://graph.facebook.com/me/friends。然后,您可以在此端点获取朋友的头像:https://graph.facebook.com/[profile_id]/picture

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

    希望这会有所帮助!

    【讨论】:

    • 谢谢你的回答,donkim!
    【解决方案3】:

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

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

    它让您只需几行代码即可使用所有 Graph API 功能。

    【讨论】:

      【解决方案4】:

      对于寻找此功能的 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 和个人资料照片网址。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-17
        • 1970-01-01
        • 1970-01-01
        • 2011-09-24
        • 2011-10-02
        相关资源
        最近更新 更多