iOS 8.3 Facebook SDK 4.1 检索用户的个人资料相册

iOS 8.3 Facebook SDK 4.1 Retrieve user's Profile Photo Album

我在我的代码中使用 Facebook SDK 最新版本 4.3。我的任务是我必须从 Facebook 的以下路径中获取名为 Profile Pictures 的用户的完整相册:UserProfile-> Photos-> Albums-> Profile Pictures。

为了实现这一点,我已经通过了@"public_profile"、@"user_photos" 等的权限...

我在 SO 上搜索了很多链接并尝试了几乎所有极客建议的合适答案。

我尝试了给定的东西 here, here,还有更多...

在我当前的场景中,我正在获取用户个人资料图片(当前),但我需要存储在他的个人资料图片相册中的所有图片。如果有人有任何想法,请帮助。

据我所知,在一个请求中无法做到这一点。您需要做两件事:

  1. 请求用户的相册,解析结果为相册"Profile Pictures"

    GET /me/albums?fields=id,name&locale=en_US

这个 returns 一个 JSON 这样的:

{
  "data": [
    {
      "id": "442898331243456464", 
      "name": "Profile Pictures", 
      "created_time": "2010-12-12T13:35:29+0000"
    }
    ...
  ], 
  "paging": {
    "cursors": {
      "after": "NDQyODk4MzMxMjQz", 
      "before": "MTAxNTA5MjQyNDQ4NDYyNDQ="
    }
  }
}
  1. 获取名为 "Profile Pictures" 的相册的 id,然后像这样请求 photos 边缘:

    GET /442898331243456464/photos

您将收到一个带有个人资料照片的 JSON 对象。如果超过 25 张照片,您可能需要对结果进行分页。

先登录facebook然后写下面的代码 您可以从 facebook 获取用户个人资料照片。

  NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
            [parameters setValue:@"id,name,email,picture" forKey:@"fields"];

            [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
             startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result, NSError *error)
            {
                NSLog(@"Your get the result here contain userid, name, email and picture");
             }];