August 6, 2014 8:22 pm

Search Content in Facebook with Open Graph API in PHP

In this tutorial I will show you that how to search on Facebook using open graph API in PHP. Using Open Graph search you can access all public data very easily by typing your required word like “PHP” you will get all the information shared publicly on facebook contain word PHP. Its very simple and easy to integrate and you can access your required data on a single page.

Search Content in Facebook with Open Graph API in PHP

To implement this search you need to create an facebook application we have already explained how to create a Facebook application in our previous tutorial so we are not repeating same procedure again.

We need a oauth token to run open graph query so you need to authenticate first so we can get your access token from facebook and after that you can see a form where you put your keyword and search type like Post, Group, Page, Event or Place ie: you search Delhi in places it will show all places in Delhi.


Contains PHP code for facebook authentication and display lists.

Above code used to get your access token and store it in session, after that show you a form to search anything on facebook public postings. Used a class fbSearcher.php contains some functions like call Graph query url and return data to the main page you can get this class and other required files in our download script freely available.

A live demo and complete code available for download for free download code and enjoy.

I hope you like this tutorial an please don’t forget to comment below your views and suggestion for improvement.

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:
  • Mawia HL

    I tested the code, but all I could get is no result even if I type the existing fan page in the input select provided in the demo. What could be wrong? Any way I really like the idea especially for implementing in site. Go on…

  • expy movies

    I Agree with Mawia HL . we are trying to access but no result found as yet. and most unfortunate part is there is no support.

  • Irma Gerd

    Regarding the previous comments: Facebook disabled the graph search for all app keys created after 2013.

    • Jamari Johns

      whats the option as of now, please assist.

  • Anh Khoa Truong

    I like this tut. Thank’s

  • Anh Khoa Truong

    My Demo :

    Notice: Undefined index: access_token in C:xampphtdocsprojectindex.php on line 25

    Notice: Undefined index: q in C:xampphtdocsprojectindex.php on line 27

    Please tell me why ??? Thank’s.

  • Andrej Vl

    Hi ,
    I have the same problem as Anh Khoa Truong :

    Notice: Undefined index: access_token in C:wampwwwsearchindex.php on line 25

    Notice: Undefined index: q in C:wampwwwsearchindex.php on line 27

    But can’t see answer. Please help my .