How can I display Facebook Public Page Posts on my website?

  0 comments
  • Log into the Facebook account 
  • Visit https://developers.facebook.com/apps,
  • On the top right of the next screen, click on the button “+Create New App”
  • Fill all the information and proceed further 
  • On the next screen you will see “App ID:” and “APP Secret:” You will need it when requesting.
  • To get Facebook posts by request, you need to implement Facebook login system in your website

Here is the code in Drupal to implement Facebook login system

Login Code

 

To send this request you need to get "manage_pages" permission first otherwise it will give error.

Manage Page Permission Error

 

Facebook will send a code to your redirect URL and you will get the “User Access Token” with the help of this code 

User Access Token Image

 

And then you need to send the request again to get the user account information

User Account Information

 

Then you can find out which page the user has allowed and then you need to send a request to that page for the “Page Access Token”.

Page Access Token

 

Now subscribe the Facebook pages if you want to get the real time Facebook Webhook notification

Facebook Webhook

Here is a screenshot of the full code.

How to get Facebook Page Access Token in Drupal

 

If you get the page access token successfully then  you need to send a request to fetch the page posts

Public Page Post API Request

 

Now you can display these posts on your page where you want.

 

Enjoy!

Add new comment