May 19, 2016 5:47 am

How to get Facebook Page Feed with graph API using PHP & MySQL

In this tutorial I will show you that how to get Facebook pages public feed using graph API without any authentication. You can run this script on console, on local host or you can run this script on your live website. This tutorial get a Facebook page URL and Facebook application id and secret that’s it.

How to get Facebook Page Feed with graph API using PHP & MySQL

Let’s start from app creation.

Step 1: create Facebook application click here

step 1 Facebook for Developers

Step 2: Chose platform where to use application select website.

Step 2 Facebook for Developers

Step 3: Write your application name and click Create New Facebook App ID button.

step 3 Facebook for Developers

Step 4: Select settings for application and give your email.

step 4 Facebook for Developers

Step 5: Skip quick start

step 5 Facebook for Developers

Step 6: App setup from sandbox to live on review page

step 6 App Review Facebook for Developers

Final Step for application creation and setting: Copy application ID and Secret from settings page

step 7 phpgang feed app Dashboard Facebook for Developers

Read Also: How to Login with Facebook API SDK v5 in PHP

Now Coding for your feed application

Feed_database.sql

Import tables in your database.

db.php

Configure your database connection file.

config.php

Application configuration file, modify CALL BACK URLYour App ID and Your App Secret values.

index.php

Index file used to show you a form where you need to add your application unique name or id.

Page Name or page id

feed.php

This is the main file used to get page info and feeds and store in database.

This file will get latest 25 posts of your given page and store in database and display them on view.php file attached in download source code.

Note: If you want to get feed comments+comments reply code please contact us.

Thanks for reading my tutorial please write down your feedback in comments to improve PHPGang.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:
  • Nguyen Cuong

    Hi i get error: undefined function file_get_contents_curl()
    pls help

    • That function available in feed.php file download code you will get that.

      You can also use file_get_content() php builtin function.

  • Santhosh Kumar

    can you help me it is not working

  • Santhosh Kumar

    my skype id is santhosh.kumar.hegde

  • Santhosh Kumar

    It is working now
    how to get page details
    page name and fan count from this code

    • John Kerim

      fuctions.php

  • Nice blogpost.

  • Mick

    Thanks for this! Again a great tutorial. Grtz from The Netherlands!

  • Arno

    Why the database? Can’t you just retrieve the data and publish it?

  • shahid khan

    it doest allow me to download due to subscription i cant subcribe it
    could any one know how to download it?

  • shahid khan

    its taking to much time to subscribe…
    is their any other way to download this
    hello any one ?

  • alykhan

    Subscribe button is broken