Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get Facebook Graph api page review

Tags:

I'm trying to get review/rating from certain place whos fb page can look like this i.e :

https://www.facebook.com/pages/Dell-Rheas-Chicken-Basket/183254918389428

So id of this place/page is 183254918389428

And you can get the details of this place but not rating/review:

https://graph.facebook.com/183254918389428

I found somewhere on this forum that you could get review from page like this :

https://graph.facebook.com/183254918389428/tabs/reviews?access_token=xxx

But I always get no data :

{    "data": [     ] } 

So I'm not trying to get app review/rating but for certain place.

like image 801
ant Avatar asked Jun 26 '13 09:06

ant


2 Answers

You'd need a page access token to fetch reviews and ratings. Here is a very good short tutorial on getting a page access token: Obtaining page access token.

https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=<REDIRECT_URL>&scope=manage_pages&state=<STATE> 

This will generate you a CODE, use that code in:

https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>&client_secret=<APP_SECRET>&code=<CODE> 

This will return you a json response containing short lived user access token.

Next, use the short lived user token to get long lived user token:

https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=<APP_ID>&client_secret=<APP_SECRET>&fb_exchange_token=<SHORT_LIVED_TOKEN> 

This will return another json containing the long lived user token, you can now exchange it for page access token:

https://graph.facebook.com/me/accounts?access_token=<LONG_LIVED_TOKEN> 

This will return you a json with page access token of the page(s) associated with that user account. Use this page access token to fetch ratings and reviews by passing it to:

https://graph.facebook.com/StoneArmsInc/ratings?access_token=<page_access_token> 

And you will get all the ratings posted on facebook for that page.

Hope, this helps someone. :)

like image 144
Criesto Avatar answered Oct 29 '22 07:10

Criesto


The ratings edge has the reviews in it now, but you need to have a page access token to get it.

The end point is documented here:

https://developers.facebook.com/docs/graph-api/reference/page/ratings

Note that to get the page access token you have to use a user token from someone who is an admin of the page. I don't know if that's a problem for you.

like image 30
Eli Omernick Avatar answered Oct 29 '22 08:10

Eli Omernick