Home » Php » javascript – How to get all google reviews using business api

javascript – How to get all google reviews using business api

Posted by: admin July 12, 2020 Leave a comment

Questions:

I need all google reviews for particular location but I am unable to use business api from google. Here is url for get request

https://mybusiness.googleapis.com/v3/accounts/account_name/locations/location_name/reviews 

Now my question is what is the value for param account_name and location_name
How can I get that.

Please answer with sample location example

How to&Answers:

I think first of all you need to white list your google my business api for whatever project you are working on in your project as its private api. Google my business api will work on the locations associated with your account so make sure you verified the LOCATIONS from any account you know. Then you can try out the api call you mentioned in OAuthplayground.

  1. Follow steps mentioned in below documentation URL to set it up:
    https://developers.google.com/my-business/content/prereqs

After the setup and etc you will automatically understand the account id and location id.

Also few more urls you can go to understand it better.

  1. https://console.developers.google.com (here you will setup your project)
  2. https://business.google.com/manage (here you will add/can see the locations – for which you need reviews)
  3. https://developers.google.com/my-business/content/basic-setup (Steps after completing the prereq)
  4. https://developers.google.com/oauthplayground (You will test the my
    business api here after approval)

Answer:

When you make a request to https://mybusiness.googleapis.com/v3/accounts it gives you a list of accounts. On those accounts they have a field called name. That field is accounts/account_name.

{
  "state": {
    "status": "UNVERIFIED"
  }, 
  "type": "PERSONAL", 
  "name": "accounts/1337", 
  "accountName": "example"
}

When you make a request to https://mybusiness.googleapis.com/v3/accounts/account_name/locations it gives you a list of locations. On those locations they have a field called name. That field is accounts/account_name/locations/location_name.

{
  "locations": [
    {
      "languageCode": "en", 
      "openInfo": {
        "status": "OPEN", 
        "canReopen": true
      }, 
      "name": "accounts/1337/locations/13161337", 
      ...
}