facebook graph - 检索多张照片

Posted

技术标签:

【中文标题】facebook graph - 检索多张照片【英文标题】:facebook graph - retrieve multiple photos 【发布时间】:2016-05-18 14:38:38 【问题描述】:

我想检索可以在单个 Facebook 帖子中发布的所有照片。 例如,在这个post 中,有两张照片。 使用 Graph API (https://graph.facebook.com/v2.6/AtifAslamOfficialFanPage/posts?fields=id,type,created_time,link,message,source,object_id&limit=10&access_token=xxx) 我得到这篇文章:


     "id": "182973122142_10153437154822143",
     "type": "photo",
     "created_time": "2016-03-18T17:47:23+0000",
     "link": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3",
     "object_id": "10153437154412143"
  

但只有一个object_id,即帖子的第一张照片。

是否可以检索所有照片?

【问题讨论】:

【参考方案1】:

请求attachments字段,182973122142_10153437154822143?fields=attachments,会得到如下数据结构:


  "attachments": 
    "data": [
      
        "subattachments": 
          "data": [
            
              "media": 
                "image": 
                  "height": 266,
                  "src": "https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/10314482_10153437154412143_7582591571482186627_n.png?oh=a2b350ce8ac6ae546022295c7e73245a&oe=579E6E12",
                  "width": 720
                
              ,
              "target": 
                "id": "10153437154412143",
                "url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3"
              ,
              "type": "photo",
              "url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3"
            ,
            
              "media": 
                "image": 
                  "height": 720,
                  "src": "https://scontent.xx.fbcdn.net/v/t1.0-9/p720x720/10314505_10153437154507143_8615151666809542144_n.jpg?oh=4255fb5699cf0a4d5c455be82cbb8efe&oe=57E38281",
                  "width": 720
                
              ,
              "target": 
                "id": "10153437154507143",
                "url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154507143/?type=3"
              ,
              "type": "photo",
              "url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154507143/?type=3"
            
          ]
        ,
        "target": 
          "id": "10153437154822143",
          "url": "https://www.facebook.com/AtifAslamOfficialFanPage/posts/10153437154822143"
        ,
        "title": "Photos from Atif Aslam's post",
        "type": "album",
        "url": "https://www.facebook.com/AtifAslamOfficialFanPage/posts/10153437154822143"
      
    ]
  ,
  "id": "182973122142_10153437154822143"

【讨论】:

以上是关于facebook graph - 检索多张照片的主要内容,如果未能解决你的问题,请参考以下文章

Facebook Graph API:发布包含多个视频和照片的帖子

Facebook Graph API和FQL就像照片一样都不正确吗?

使用 iOS SDK 将多张照片作为单个帖子上传,例如时间线照片,而不是 Facebook 中的相册

如何从 Instagram 上的多张照片中检索所有图像

如何使用 iPhone 中的 Graph API 在 Facebook 上上传照片?

Facebook Graph API - 按用户标签获取照片