Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Use Google My Business Api to get the reviews , and reply to that

If I have api key of Business API, i just want example of URL, like how to put the place id and api key.

like image 801
Praveen Hegde Avatar asked Dec 28 '17 12:12

Praveen Hegde


2 Answers

If Google have authorized you to use Google Business API then you need to

  • Authenticate the user via OAuth.
  • After authentication which will give you the token, API will return you the users's account.
  • Now to get the reviews you have to make Http Get request to the endpoint below https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationid}/reviews

Your Http Get request must have Access Token
For Example: https://mybusiness.googleapis.com/.../reviews??access_token={tokenHere}
this will return you all the reviews.
Ref: https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews
Hope that answered your Question.

like image 194
Danyal Malik Avatar answered Oct 23 '22 02:10

Danyal Malik


*Please note, support of v3 of the API ended on March 10, 2018; v3 will no longer be available on May 10th 2018. So we encourage you to migrate to v4.1 as soon as possible to prevent any interruption in functionality. In addition, the deprecation schedule can be found here

You can get Google My business (GMB) reviews in same ways

Please find the below working code for review reply with PHP HTTP request

$access_token = "<your_access_token_here>";
$query = array('comment' => 'Thank you for visiting our business!');
$request_uri = "https://mybusiness.googleapis.com/v4/accounts/111050869667910417441/locations/17405754705905257334/reviews/AIe9_BFu3rdicGrPrzdyu4PDXmqMAu-9BCJf9_HF0DxzGxsjAGw5KGl1XsdqSkbsAMdl_W2XBG4bwO3wCp0_l_8KLAV7mckl5cSyJItwPqSYGiH3ktK6nrI/reply?access_token=" . $access_token;
$curinit = curl_init($request_uri);
curl_setopt($curinit, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curinit, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curinit, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($curinit, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curinit, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json',
  'Content-Length: ' . strlen(json_encode($query)))
);
$json = curl_exec($curinit);
$phpObj = json_decode($json, true);
var_dump($phpObj);
like image 31
Mohd Abdul Baquee Avatar answered Oct 23 '22 00:10

Mohd Abdul Baquee