get Facebook Graph api page review - facebook

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.

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. :)

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.

The API for Page reviews hasn't been released yet. We are working on it. Please keep checking for the updates here.
Update: API for fetching page reviews can be found here: https://developers.facebook.com/docs/graph-api/reference/page/ratings/

Related

Viewing graph api via url not showing data

So I have been watching some tutorials about the facebook graph API, and one of the things in the video is to simply navigate to http://graph.facebook.com/youtube
and it should display a json response of their facebook likes etc. This is said to work without an access token?
But this doesn't seem to work, i get the following response -
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104,
"fbtrace_id": "DoY144sSuti"
}
}
Has something changed that you will need to always need an access token just to see peoples data, eg how many likes a page has?
Has something changed that you will need to always need an access token just to see peoples data, eg how many likes a page has?
Yes. Since API v2.0, all API calls (with the profile picture redirect being the exception) need to use an access token.
Public data about public pages can be accessed using an app access token; if the page is not public it needs a user access token for a user that can see the page, or a page access token. (More about the different types of token here: https://developers.facebook.com/docs/facebook-login/access-tokens)
This is said to work without an access token?
Then that tutorial is simply outdated.
Yes you will need the access token in order to view that Jason data in URL .
try this Instead :
https://graph.facebook.com/page-id/posts?access_token={your-access- token}
You will be able to see the posts now.Hope this would help you .

Get facebook public page rating and review

I am not the owner of some page but i want access the pages reviews and ratings,Each access time i am getting empty data set
> http="https://graph.facebook.com/102227700571/tabs/reviews?access_token=fb_oauth"
> content=callAPIInfo(http,fb_oauth)
> content
$data
list()
I saw some of the similar12 question but didnt get my answer,I dont wanna collect page access tokens from the admin of each pages,Is it possible to fetch review and rating.thanks.
EDIT
Finally i find a very detailed answer by ifaour for access pages token by admin and its necessary to take page access token so here is how to get page access token and review and rating
Go to the Graph API Explorer
Choose your app from the dropdown menu
Click "Get Access Token"
Choose the manage_pages permission (you may need the user_events permission too, not sure)
Now access the me/accounts connection and copy your page's access_token Click on
your page's id Add the page's access_token to the GET fields Call
the connection you want (e.g.: PAGE_ID/events)
access_token="xxx" #[what u find above]
> content=callAPIInfo(http,access_token)
> content
$data
$data[[1]]
$data[[1]]$created_time
[1] "2014-04-13T11:37:26+0000"
$data[[1]]$reviewer
$data[[1]]$reviewer$name
[1] "abc"
$data[[1]]$reviewer$id
[1] "100000579606903"
$data[[1]]$rating
[1] 4
$data[[1]]$review_text
[1] "Enjoy having coffee here...:)"
See, all-most all the graph API calls needs an access token for access else you'll not get the result.
The different APIs require different kinds of access tokens, some required current user's access token, some requires page access token and some require app access token. And there are also some APIs that can use either of these tokens.
You want to get the rating/reviews of a page. If you read the official documentation for the same (/{page-id}/ratings), it clearly says-
A page access token is required to retrieve this data.
So you have to have the page access token to get the ratings/reviews of that page. (and for that you should add manage_pages permission and get the page access token with /{page-id}?fields=access_token)

creating album and posting a photo in facebook page

I'm trying to create an album and post photo to it , these operations have to be done on a "facebook page". Before writing any code i tested it on graph api explorer :
i tries following to create an album
/page_id/albums method:post
fields :
name : "test"
access_token : "valid access_token"
i got the above mentioned access token after granting permissions like :manage_pages , photo_upload . Any ideas where i might be going wrong.
I have gone through the documents and stackoverflow questions but can't seem to figure out the problem.
i resolved the error , we have to set the access token to access token of the page . the access token can be obtained by issuing :
/me/accounts using get method.
also important thing is this will only show the list of pages to which the current user is admin to.
the access token received from the graph explorer is valid for only 1 hour, but if you receive the access token by issuing $facebook->api('/me/accounts') in php then that access token never expires.
to check if the access token is valid and related info the following link can be used to check:

Can we get a facebook access token by providing email and password in the code?

I would like to get the photo urls from the from this album:
https://graph.facebook.com/175758929145317/photos
If you access it without providing an access token, then you will get empty data:
{
"data": [
]
}
But if you first generate an access token here:
http://developers.facebook.com/tools/explorer?method=GET&path=175758929145317%2Fphotos
And then you append it to the url like this, you can get the data:
https://graph.facebook.com/175758929145317/photos?access_token=your_access_token
However, this access token cannot be used forever, it will expire.
I would like to dynamically take the photo urls from https://graph.facebook.com/175758929145317/photos and display the images on a webpage, the person who views this webpage does not need to have a facebook account.
So every time the webpage is viewed, I am thinking about if it's possible to simply use my facebook account to login (by hardcoding the email and password) and then obtain a new access token so that I can get the photo urls.
Is this possible? Or is there a better solution to my problem? (I cannot ask the album owner to change his album to public)
it's not possible, you cannot authenticate in FB using hardcoded (or stored) login/password - as per Facebook policy:
I. Features and Functionality
...
3 - You must not include functionality that proxies, requests or
collects Facebook usernames or passwords.
what you can do instead:
Get (and then extend) token for yourself (see scenario 4 in this document: https://developers.facebook.com/roadmap/offline-access-removal/). That extended token should be good for 60 days - and then you might be able to extend it again.
Try to get those photos using APPLICATION token - and if it works, then the token is good forever: https://developers.facebook.com/docs/authentication/applications/

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.