Display Facebook Page Reviews On Your Website

Rating: 5.0. From 1 vote.
Please wait...

Hey Developers,

Today we are going to introduce you with Facebook API’s. There are various Facebook API’s available which lets you pull Facebook data and display on your own website Today we are going to tell you about how you can display your Facebook page Reviews on your website with proper authorization.

So, Lets Start

To pull out Reviews from Facebook Page you require PAGE ACCESS TOKEN provided by Facebook.

To create Facebook PAGE ACCESS TOKEN follow these simple steps.

  1. Go to https://developers.facebook.com and navigate to tools & support present at top menu.
  2. Now login your Facebook Account and go to Graph API Explorer.
  3. Now Click on the Get Token Button and select Get Page Access Token Option and select the page for which you want to generate the token.
  4. Copy and Token and paste it at a suitable place for future use.

 

Now Upon creating token let’s move to coding part where we will request page reviews with help of authorized Access Token from Facebook.

Create a page ratings.php

We will use PHP Function file_get_contents to request the resources from Facebook.

Lets start

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
 $results = file_get_contents('https://graph.facebook.com/YOUR PAGE NAME OR ID/ratings?access_token=YOUR ACCESS TOKEN'); //get the result from Facebook Server in JSON Format

$a=json_decode($results,true); //Decode the results and convert into array by using true as second parameter

$b=count($a['data']); //Count the no. of results to iterate over it

for($i=0;$i<$b;$i++) //iterate over the data
{
?>

<!--Here you can embed the reviews in your suitable design-->

<p><?php echo $a['data'][$i]['reviewer']['name'];?></p>  //Print reviewer name
<p><?php echo $a['data'][$i]['rating'];?></p>              //Print ratings

Reviews are : <?php if(!empty($a['data'][$i]['review_text'])){ echo $a['data'][$i]['review_text'];
                                                     //Print description written by reviewer if available.

 }
 }

?>

So this the simple way how you can actually pull out reviews from Facebook Page and display it to your website to give more crediblity to your site.

We hope this tutorial will help you and will give youa sniff idea on how your can access resources from Facebook with proper authorization.

To get the working demo Download

You can also view our latest trending topics

Compress Images before upload in PHP

Disable Past Dates Or Upcoming Dates In PHP Datepicker

Cheers!
Because we believe Hurdles aren’t really Hurdles

3 Comments

  1. Silvio said:

    Great script, i loved it! Simple and objective.

    Rating: 4.0. From 1 vote.
    Please wait...
    July 2, 2017
    Reply
  2. Nikunj said:

    its great,
    but how we get access token without Go to https://developers.facebook.com and navigate to tools & support present at top menu.

    No votes yet.
    Please wait...
    August 14, 2017
    Reply
    • Saurabh Dubey said:

      You have to generate Access token to use any of the Facebook Graph API

      No votes yet.
      Please wait...
      August 14, 2017
      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
4 × 14 =