如何使用Graph API在一个帖子中获取所有照片?

时间:2013-01-17 02:47:26

标签: facebook facebook-graph-api post facebook-fql

  {
    "id": "11882030_4952296803730", 
    "from": {
      "name": "xxx", 
      "id": "11882030"
    }, 
    "message": "test", 
    "picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/408410_4952294483672_298434229_s.jpg", 
    "link": "https://www.facebook.com/photo.php?fbid=4952294483672&set=pcb.4952296803730&type=1&relevant_count=2", 
    "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/og8V99JVf8G.gif", 
    "actions": [
      {
        "name": "Comment", 
        "link": "https://www.facebook.com/11882030/posts/4952296803730"
      }, 
      {
        "name": "Like", 
        "link": "https://www.facebook.com/11882030/posts/4952296803730"
      }
    ], 
    "privacy": {
      "description": "Friends", 
      "value": "ALL_FRIENDS", 
      "friends": "", 
      "networks": "", 
      "allow": "", 
      "deny": ""
    }, 
    "place": {
      "id": "471607792876974", 
      "name": "TTT", 
      "location": {
        "street": "", 
        "zip": "", 
        "latitude": x, 
        "longitude": x
      }
    }, 
    "type": "photo", 
    "status_type": "mobile_status_update", 
    "object_id": "4952294483672",
    "application": {
      "name": "Facebook for iPhone", 
      "namespace": "fbiphone", 
      "id": "6628568379"
    }, 
    "created_time": "2013-01-17T01:29:59+0000", 
    "updated_time": "2013-01-17T01:29:59+0000", 
    "comments": {
      "count": 0
    }
  }

如上所述,我发布了两张照片的状态。我可以在picture中获取第一张照片的拇指网址以及相关链接&计算link中的信息。

但我怎样才能获得每张照片的特定网址?

2 个答案:

答案 0 :(得分:9)

FQL通常提供比Graph API更多的信息。您必须使用attachment FQL 表格的stream参数来获取所有附加的照片。

SELECT attachment FROM stream 
 WHERE source_id = me() 
   AND post_id="11882030_4952296803730"

结果:

{
  "data": [
    {
      "attachment": {
        "media": [
          {
            "href": "https://www.facebook.com/photo.php?fbid=471082296...", 
            "alt": "", 
            "type": "photo", 
            "src": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/5826...", 
            "photo": {
              "aid": "4391039135", 
              "pid": "439104482145", 
              "fbid": 471507, 
              "owner": 102832, 
              "index": 1, 
              "width": 485, 
              "height": 172, 
              "images": [
                {
                  "src": "https://fbcdn-photos-a.akamaihd.net/hph...", 
                  "width": 130, 
                  "height": 46
                }
              ]
            }
          }
        ], 
        "name": "", 
        "caption": "", 
        "description": "", 
        "properties": [
        ], 
        "icon": "https://fbstatic-a.akamaihd.net/rsrc.phpjk.gif", 
        "fb_object_type": "album", 
        "fb_object_id": "4391044992857139135"
      },
      { 
        ... //Photo 2
      }
    }
  ]
}

答案 1 :(得分:3)

基于StéphaneBruckerts的回答;你在attachments之后。因此,我建议您只需在图表请求中请求attachments字段。