DEV Community

Zsolt László
Zsolt László

Posted on

Embed Google reviews

Hi everyone,
I’m trying to display all Google Business reviews on my website, including reviewer name, star rating, and comment.

Here’s what I have so far:
I have a Google Cloud project and enabled the Google Business Profile API.
I have the Account ID and Location ID for the business.( I could not get it form API, I am just guessing those are the IDs)
I also have a token (access token / refresh token).( token.json with refresh token and access token too, but as I mentioned I am not sure)

The problem is:
I’m not sure if the token I have is valid or not.
I don’t know if my OAuth2 setup is correct.
I want to fetch all reviews with PHP and then embed them into HTML on my website.
I’ve tried reading token.json / google_tokens.json and using the access token in PHP, but I always get errors or empty results.

In summary I know I need oauth2, accountID, locationID, access token, redirect url, clientID, client secret.

Questions:

  1. How can I verify that my access token and refresh token are valid?

  2. How can I get and use the Account ID, Location ID, and tokens to fetch all reviews reliably?

  3. Is there a recommended way to automatically refresh tokens in PHP so I don’t have to generate new ones every hour?

  4. Ultimately, how can I output all reviews in HTML with reviewer name, stars, and comment?

Any help, code examples, or guidance on the correct flow would be greatly appreciated!

Top comments (0)