I know this question is common, however, I couldn't find any straight answers. All the answers have mentioned what is required to achieve this but no end solutions at all. Neither de G Docs are straightful on that. I´m trying to use the Google My Business API to get the reviews and ratings for a company wtih a group of locations fully verified by Google. (https://developers.google.com/my-business/content/review-data) My only one Goal for now is to list all Google Reviews, and display them on the website of the company. Make an API call (properly GET) via Ajax/PHP, or likely. API response with a list of google reviews (JSON format) Display the results in HTML.
- I have already followed the Prerequisites instruction step by step: Already have approval and test my API Creds with OAuth2 playground, and it's working fine. I managed to get the {accoundId} and {locationId} (https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/) I managed to fetch all the reviews by adding access token - (https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/?access_token=token), But that's all been done through the OAuth2playground - The issue is I want to display the reviews on the website not by Google OAuth playground as it will get expired and reviews will not be updated automatically on the website.
I couldn't find any PHP / Javascript Code examples to start implementing this on company´s website. I was slightly confused about how to use the Google PHP Client Library for that. Too many ways, but none worked at my tests (https://github.com/googleapis/google-api-php-client)
If so, would this approach, will always prompt to ask the user to select which account to log in to? which is not the behavior I am looking for. I only want to get all the reviews and display them on the website, which should not require any login for the user.
It would be helpful if you could share the code and procedure.
Thanks in advance for any help. Best regards
Google lets you pull 5, it's been this way for a long, long time.
I wrote an API that interfaces with Google to do what you need, all you need is the Place ID and you can get the historic reviews, once you obtain historic reviews you can use the native API for real-time, don't hammer the API else it'll cap you :)
Hope it helps, see demo URL below (just swap the place ID with the ones you need and save what you consume to reviews.json and you have historic ratings).
https://api.reviewsmaker.com/gmb/?placeid=ChIJCezbnsal2YgRySx0GXk5hEo