Search code examples
springfacebook-graph-apirestfb

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


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?


Solution

  • 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.