is it possible to get page reviews and reviewer's name and profile photo url with restFB library?

426 views Asked by At

I have found restFB client library in spring for facebook graph api , i have to get page reviews and reviwers name and profile photo. I am searching for this in https://restfb.com/javadoc-3/com/restfb/types/Page.html , but couldn't find any method for this

is it possible to get page reviews and reviewer's name and profile photo url with restFB library?

2

There are 2 answers

2
Norbert On BEST ANSWER

Getting the ratings is a bit more tricky.

Let's assume you have a FacebookClient with the correct page access token. Then you can start a call like this:

Connection<OpenGraphRating> ogRatingConn = 
      facebookClient.fetchConnection("me/ratings", 
           OpenGraphRating.class, 
           Parameter.with("fields", "reviewer,review_text,has_rating,recommendation_type"));

Then you can iterate over the connection. Check the OpenGraphRating object for the methods you can use.

I suggest additionally to check the open_graph_story field, because with this you can get some more information. Then the request looks like this (for the ease of use I removed the other OpenGraphRating fields here).

Connection<OpenGraphRating> ogRatingConn = 
      facebookClient.fetchConnection("me/ratings", 
           OpenGraphRating.class, 
           Parameter.with("fields", "open_graph_story{id,from,message,publish_time,type,data{recommendation_type,rating,language,review_text},comments.limit(0).summary(1).filter(stream)}"));

In this example you can access the fields with the getOpenGraphStory method that is part of the OpenGraphRating object.

0
Shah Nirjhor On

Use facebook official api

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

/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{page-id}/ratings',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */