AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

My Business
4.4K members online now
4.4K members online now
For developers who are using the Google My Business API to manage locations
Guide Me

Unable to get review listing for Location using PHP

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am using Google MyBusiness API for fetching all business reviews. But I am unable to get it with PHP syntax and GET, POST method use in MyBusiness.


I am sure that I am missig something with syntax or param pass to the function so please guide me with some sample of PHP code using MyBusiness api. Have done oAuth 2.0


Here is my code where I am passing my location name. Also I want to know that can i get other accounts location info?


$mybusinessService = new Google_Service_Mybusiness($client);
$reviews = $mybusinessService->accounts_locations_reviews;
echo '<pre>';print_r($reviews->get('ArtechDev'));exit;

With above code I am getting error 404 (Fatal error: Uncaught exception 'Google_Service_Exception' with message)


1 Expert replyverified_user

Re: Unable to get review listing for Location using PHP

Google Employee
# 2
Google Employee

Hi @GoHotNews C,


Please make sure you are using the OAuth 2.0 installed application flow and persisting the refresh token for your application so that it will always be able to request a new access token when necessary. We suggest you please checkout this thread for fetching all business reviews for specified location with the Google API Client Library for PHP.


You can also check out this Accepted Solution for setting up a service account with v1-branch of the Google API Client Library for PHP and the PHP client library.


Note that PHP client library doesn’t currently support the display of detailed error messages. Please follow the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.



The Google My Business API team