2

我正在正确获取 json 格式,但问题是我想一张一张地检索相册图像并将其显示在网格视图中...请任何人提出一些代码或想法...请建议我如何获取每张照片的相册 ID专辑

  Results: {
         data =     (
        {
    "can_upload" = 1;
    count = 2;
    "cover_photo" = 1404379296458611;
    "created_time" = "2013-10-04T11:35:21+0000";
    from =             {
        id = 100006596624401;
        name = "sample";
    };
    id = 1404366983126509;
    link = "https://www.facebook.com/album.php?fbid=1404366983126509&id=100006596624401&aid=1073741827";
    name = "Photos";
    privacy = custom;
    type = app;
    "updated_time" = "2013-10-09T07:41:48+0000";
},
        {
    "can_upload" = 0;
    "created_time" = "2013-10-08T10:55:52+0000";
    from =             {
        id = 100006596624401;
        name = "sample";
    };
    id = 1406014439628430;
    link = "https://www.facebook.com/album.php?fbid=1406014439628430&id=100006596624401&aid=1073741829";
    name = "he Photos";
    privacy = custom;
    type = app;
    "updated_time" = "2013-10-08T11:33:49+0000";
},
        {
    "can_upload" = 0;
    count = 1;
    "cover_photo" = 1405547679675106;
    "created_time" = "2013-10-07T06:21:36+0000";
    from =             {
        id = 100006596624401;
        name = "sample";
    };
    id = 1405547666341774;
    link = "https://www.facebook.com/album.php?fbid=1405547666341774&id=100006596624401&aid=1073741828";
    name = test;
    privacy = everyone;
    type = normal;
    "updated_time" = "2013-10-07T06:21:47+0000";
},
        {
    "can_upload" = 0;
    "created_time" = "2013-09-25T05:30:31+0000";
    from =             {
        id = 100006596624401;
        name = "sample";
    };
    id = 1399900213573186;
    link = "https://www.facebook.com/album.php?fbid=1399900213573186&id=100006596624401&aid=1073741825";
    name = "iOS Photos";
    privacy = everyone;
    type = app;
    "updated_time" = "2013-09-25T06:26:13+0000";
}
);
paging =     {
    cursors =         {
     after = "MTM5OTkwMDIxMzU3MzE4Ng==";
    before = "MTQwNDM2Njk4MzEyNjUwOQ==";
};
  };
4

2 回答 2

3

试试这个

    FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:@"me/albums" withGetVars:nil];
    NSDictionary *albums = (NSDictionary *)[fb_graph_response.htmlResponse JSONValue];
    NSMutableArray * albumids = [[NSMutableArray alloc] init];
    albumids = [albums objectForKey:@"data"];

    for(int i =0; i< [albumids count]; i++)
    {
        NSDictionary *dictuser = (NSDictionary *)[albumids objectAtIndex:i];
        [album addObject:[dictuser objectForKey:@"id"]];
        [albumname addObject:[dictuser objectForKey:@"name"]];
    }
于 2013-10-18T10:39:56.313 回答
0

斯威夫特 4.0 版本

let request = FBSDKGraphRequest.init(graphPath: "/me/albums", parameters: ["fields": "photo_count,name,id" ], httpMethod: "GET")
    request?.start(completionHandler: { (connection, result, error) in

    })

如果您想获取相册的图片,请使用此

"fields": "photo_count,name,id,picture"

Facebook 也有一个非常有用的Graph Api Explorer

于 2018-04-06T10:45:05.747 回答