Its a very broad question. Anyways, just follow these steps-
If you are not registered as a facebook developers, register here: https://developers.facebook.com/
Then, create an app from here: https://developers.facebook.com/apps
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.Get the contents using
curl
orfile_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!