Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google My Business API to fetch Reviews

I want to know how can I use GMB API to fetch reviews. According to google documentation we have to make a GET request to https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}/reviews

But what is meant by {name=accounts/*/locations/*} and from where we can get the value of accounts & locations.

Also this requires OAuth 2.0. If I get a access_token then GET request will be like this:- https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}/reviews?access_token=token

This is very confusing. Can somebody tell me how to use GMB API correctly to fetch google reviews.

like image 316
Puneet Pant Avatar asked Nov 01 '25 17:11

Puneet Pant


1 Answers

Using Google OAuth 2 Playground For testing acquisition of Google reviews

  1. Create a project
    • Console.cloud.google.com
    • Sign in as {projectowner}@google.com
    • Select a project from the dropdown in the header or click new project
  2. Go to APIs & Services in the left menu
  3. Enable the Google My Business API; this requires validation by Google and may take a couple of days. They will email you.
  4. Go to developers.google.com/oauthplayground
  5. Using the settings gear, set OAuth flow to Client-side and click Use your own OAuth credentials
  6. Get the client id from console.developers.google.com/apis and paste it in
  7. Put this into scope: https://www.googleapis.com/auth/plus.business.manage and authorize it with {projectowner}@gmail.com
  8. Exchange auth code for token
  9. To get the account name:
    • Set Request URI to https://mybusiness.googleapis.com/v4/accounts and send a Get request
    • Copy the entire string value at “name”: not including quotes; it may be 20+ numeric digits
  10. To get location names:
    • Set Request URI to https://mybusiness.googleapis.com/v4/accounts/{paste account name here}/locations where {paste ... here} is the account name you copied
    • The returned JSON contains all of your locations
    • Copy the location names including quotes and commas to a temporary holding document; they will be used in a JSON array in the next step
  11. To get multiple locations’ reviews a. Set Request URI to https://mybusiness.googleapis.com/v4/accounts/{account name here}/locations:batchGetReviews and the Method to Post b. Set Request Body to { "locationNames": [ "accounts/999999999999999999999/locations/88888888888888888888", "accounts/999999999999999999999/locations/77777777777777777777", . . . "accounts/999999999999999999999/locations/11111111111111111111" ], "pageSize": 200, "orderBy": "updateTime desc", "ignoreRatingOnlyReviews": false }

using the account names you saved from the location JSON for each line of the array

  1. If you have more than 200 total reviews you will have to add "pageToken": string into the JSON body where string is a value returned in the preceding POST.
like image 88
DickoVan Avatar answered Nov 04 '25 09:11

DickoVan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!