0
votes

I am attempting to display the latest post from a public Facebook page on a website using the graph API.

Using the following URL, I am able to get the latest posts data:

https://graph.facebook.com/MYPAGENAME/posts?access_token=MYACCESSTOKEN

Which returns:

 {
   "data": [
            {
             "story": "MYPAGENAME added a new photo.",
             "created_time": "2017-08-20T19:00:00+0000",
             "id": "MYID"
            }

      ...

The post in question displays on the Facebook page with a photo included, but there is not 'photo' object (or anything similar) returned in the API data. How do I access the picture URL for this post? Thanks in advance.

1
The full_picture field usually contains a larger version of the image used. You have to ask for the field, of course, as you generally need to do since API v2.4; if that doesn’t mean anything to you, then go read the docs chapter on basic API usage first. - CBroe
also, if you only want to get the latest post, use the limit parameter - luschn
Thanks @CBroe and luschn - I ended up using '...?fields=full_picture...'. Marked CoGe's answer right as it's correct, just not best for my particular case. - SilentDesigns

1 Answers

4
votes

Use

/posts?fields=attachments{media}?access_token={youraccesstoken}

and you will get the media Data of your posts.