Search code examples
javafacebookfacebook-graph-apirestfbfacebook4j

Using Facebook API to retrieve Page reviews using Java


We have a number of Java-based websites, for each we would like to extract all Reviews from a specified Facebook page (different for each website) and show them on a page on the website - basically we are amalgamating reviews from different sources into one place.

We would like to periodically extract the reviews and cache them in the Java app to avoid having to go to Facebook (among other review soures) every time the page is viewed.

I have looked at restfb.com and also Facebook4J and both look like good solutions.

I'm not clear how the access token and login would work. Ideally we would only want a customer to grant access once and then for the review extraction to work without manual intervention. Is it possible to have a for-ever or very long-lived access token?

How do other FB data-extraction tools work to avoid user having to OK the access every time?


Solution

  • You need to use an Extended Page Token, it is valid forever:

    • Authorize a Page Admin with the manage_pages permission
    • Extend the User Token
    • Get an Extended Page token with /page-id?fields=access_token

    More information: