Api Google My Business Listaccounts not working?

Viewed 149

I regularly used the 4.9 api to list the accounts where I am an administrator in GMB.

https://developers.google.com/my-business/reference/rest

I am trying to update my code following the deprecation of the listaccount function https://developers.google.com/my-business/reference/rest/v4/accounts/list

I have the same approach with the api 1.1 https://developers.google.com/my-business/reference/accountmanagement/rest/v1/accounts but it's not working like I want.

This is my code (with Oauth access):

use Google_Client;
use Google\Service\MyBusinessAccountManagement;
use Google\Service\MyBusinessBusinessInformation;

$accountManagement = new MyBusinessAccountManagement($client);
  
$mb_accounts = $accountManagement->accounts->listAccounts();
var_dump($mb_accounts);

$accountsList = $mb_accounts->getAccounts();
var_dump($accountsList);

this returns the information concerning my account but not the list of accounts where I am an administrator

object(Google\Service\MyBusinessAccountManagement\ListAccountsResponse)#59 (8) { ["collection_key":protected]=> string(8) "accounts" ["accountsType":protected]=> string(50) "Google\Service\MyBusinessAccountManagement\Account" ["accountsDataType":protected]=> string(5) "array" ["nextPageToken"]=> NULL ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } ["accounts"]=> array(1) { [0]=> object(Google\Service\MyBusinessAccountManagement\Account)#54 (14) { ["accountName"]=> string(13) "prenom nom" ["accountNumber"]=> NULL ["name"]=> string(30) "accounts/mynumberaccount" ["organizationInfoType":protected]=> string(59) "Google\Service\MyBusinessAccountManagement\OrganizationInfo" ["organizationInfoDataType":protected]=> string(0) "" ["permissionLevel"]=> NULL ["primaryOwner"]=> NULL ["role"]=> NULL ["type"]=> string(8) "PERSONAL" ["verificationState"]=> string(10) "UNVERIFIED" ["vettedState"]=> string(10) "NOT_VETTED" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } } } }


array(1) { [0]=> object(Google\Service\MyBusinessAccountManagement\Account)#54 (14) { ["accountName"]=> string(13) "prenom nom" ["accountNumber"]=> NULL ["name"]=> string(30) "accounts/mynumberaccount" ["organizationInfoType":protected]=> string(59) "Google\Service\MyBusinessAccountManagement\OrganizationInfo" ["organizationInfoDataType":protected]=> string(0) "" ["permissionLevel"]=> NULL ["primaryOwner"]=> NULL ["role"]=> NULL ["type"]=> string(8) "PERSONAL" ["verificationState"]=> string(10) "UNVERIFIED" ["vettedState"]=> string(10) "NOT_VETTED" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } } } 

What is my mistake ?

0 Answers
Related