My awesome friend Lewis King wanted to display the latest facebook post in the footer of a site that he’s building. He’s not a developer, and facebook didn’t make it easy.

The tangled web of facebook developer documentation and inadequate access token description. Most blog tutorials out there are outdated because of the introduction of required access tokens.

My solution:

    1. Get yourself an access token (remember that you need to be an admin of the page that you want to read from). You will need to select “manage_pages” from the extended permissions section before authorising the token.
    2. Find your USER_ID by going to http://graph.facebook.com/USERNAME
    3. We have one access token, but we need to get a long-life access token for your page. You can get this and token for your apps at this URL: https://graph.facebook.com/USER_ID/accounts?access_token=ACCESS_TOKEN
    4. Take this new access token and go to: https://graph.facebook.com/PAGE_ID/promotable_posts?access_token=LONG_LIFE_ACCESS_TOKEN
    5. You will now see an object with the page’s latest posts with various fields available including the message and information about any URLs that were posts e.g. image and description.

That was the difficult bit done. It’s very simple from a code point of view to get the page post data and show the latest one and link to it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation

Innovabe Menu