skip to Main Content

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

Answers


  1. 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 `FacebookFacebookResponse` object
      $response = $fb->get(
        '/{page-id}/ratings',
        '{access-token}'
      );
    } catch(FacebookExceptionsFacebookResponseException $e) {
      echo 'Graph returned an error: ' . $e->getMessage();
      exit;
    } catch(FacebookExceptionsFacebookSDKException $e) {
      echo 'Facebook SDK returned an error: ' . $e->getMessage();
      exit;
    }
    $graphNode = $response->getGraphNode();
    /* handle the result */
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search