Question

Hi I have a facebook page (not an app), and I want to get the recent post on my website using PHP.

I don't know where to begin. I used google to look this up but all I could find was how to get post from an app.

Was it helpful?

Solution

Its a very broad question. Anyways, just follow these steps-

  1. If you are not registered as a facebook developers, register here: https://developers.facebook.com/

  2. Then, create an app from here: https://developers.facebook.com/apps

  3. Copy the app access token (app-id|app-secret) to your php script- this is required, since to fetch the posts (public) from a page, you need a valid access token.

  4. Get the contents using curl or file_get_contents of the url:

    https://graph.facebook.com/{page-id/page-username}/posts?access_token={app-access-token}
    

(You can see the result by browsing above url in a browser) Just parse the JSON and get the posts as required. You'll not get all the posts in one go, but in the result you'll have the url to the next page.

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top