Search code examples
facebookfacebook-graph-apifacebook-social-plugins

How to use Facebook Embedded Post to show the latest post using Graph API?


I want to show a Embedded Post in my website, but I want it to be always the latest post on my fanpage.

What I'm trying to do is:

  1. Query the posts by making a GET request to https://graph.facebook.com/{FANPAGE}/posts?access_token={TOKEN}
  2. Get the ID of the first object
  3. Add the plugin to DOM on runtime using the ID

The problem is that I can't figure it out how to get a permanent access token (or equivalent) - since I can't update it every time it expires and I don't want the user to login just to be able to see the plugin.

Can this be done? How?


Solution

  • You can use a page access token, or your app access token (the latter will work only if the page is not restricted and posts are not targeted to specific audiences.)

    Both of those must never be exposed in public client-side code; so you will need to do this on the server.