How to use Facebook graph API to retrieve fan photos uploaded to wall of fan page?

后端 未结 2 1942
北荒
北荒 2020-12-06 03:23

I am creating an external photo gallery using PHP and the Facebook graph API. It pulls thumbnails as well as the large image from albums on our Facebook Fan Page.

相关标签:
2条回答
  • 2020-12-06 03:57

    You need to retrieve all the albums and then get all the photos. This can be easily done by using FQL:

    SELECT pid,owner,src_small,src_big 
    FROM photo 
    WHERE aid IN (
        SELECT aid 
        FROM album 
        WHERE owner = your_page_id
    )
    

    EDIT:
    Also you need to query the stream table to get the wall posts then check if you have attachments and the type of the attachment:

    SELECT attachment
    FROM stream 
    WHERE source_id = 116860675007039
    

    Result:

    [
      {
        "attachment": {
          "media": [
            {
              "href": "http://www.facebook.com/photo.php?fbid=1801693052786&set=o.116860675007039",
              "alt": "test",
              "type": "photo",
              "src": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc6/185861_1801693052786_1553635161_1863491_4978966_s.jpg",
              "photo": {
                "aid": "6672812206410774346",
                "pid": "6672812206412558147",
                "fbid": 1801693052786,
                "owner": 1553635161,
                "index": 11,
                "width": 246,
                "height": 198
              }
            }
          ],
          "name": "",
          "caption": "",
          "description": "",
          "properties": [],
          "icon": "http://b.static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
          "fb_object_type": "photo",
          "fb_object_id": "6672812206412558147"
        }
      },
      {
        "attachment": {
          "description": ""
        }
      },
    ...etc
    ]
    
    0 讨论(0)
  • try this FQL:

    SELECT message,attachment,comments
    FROM stream
    WHERE source_id=YOUR_PAGE_ID AND filter_key="others" AND type=""
    

    filter_key="others" - this will filter posts from everyone else, but not from Admin type="" - this will filter out comments, so will leave you with photos (maybe videos and other strenge things, but removing text posts will reduce result massively)

    0 讨论(0)
提交回复
热议问题