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

Getting Error when Try to fetch Account list

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭
Hi,

I downloaded the latest google-api-php-client and successfull in genreating auth and refresh token. But when I try to fetch all the clients getting

Fatal error
: Call to a member function getLogger() on a non-object.Iam trying to fetch all the accounts under a main account

require_once 'google-api-php-client/vendor/autoload.php';
require_once'Mybusiness.php';
$client_id = 'XXXXXXXXXX'; //Google client ID
$client_secret = 'XXXXXXXXXX'; //Google client secret
$refresh_token = 'XXXXXXXXXXXXXXXX';


//Call Google API
$gClient = new Google_Client();
$gClient->setClientId($client_id);
$gClient->setClientSecret($client_secret);
$gClient->refreshToken($refresh_token);

$gClient->getAccessToken();

print'<pre>';


$gmbService = new Google_Service_Mybusiness($gClient);
$accounts = $gmbService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
echo "<pre>"; print_r($accountsList); echo "</pre>";

Please help to fix this issue.

Thanks,
Joseph
1 Expert replyverified_user

Re: Getting Error when Try to fetch Account list

Google Employee
# 2
Google Employee

Hi @silvester c,

 

We have answered your question already in another thread. Please check out this response.

 

Thanks,

Shalini

Getting Error when Try to fetch Account list

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi @Shalini S,

I was able to fix the issue. It was related to project ID.  One of your answer recently to  Forum helped me to solve it.

 

Thanks,

Joseph