Emoyaki
Emoyaki

Reputation: 105

Google Api PHP unable to pass variable to call('list')

I am trying to run the following code with the new Google Business Profile API:

$mybusinessbusinessinformationService = new Google\Service\MyBusinessBusinessInformation($client);
    try
       {
         $locations = $mybusinessbusinessinformationService->accounts_locations->call('list',['parent'=>'accounts/1111111111111111111']);
         var_dump($locations);
       } catch(Exception $e){
         var_dump(print_r($e->getMessage(),1));
       }

But I am getting the following error:

(list) missing required param: 'parent'

As far as I can tell it seems that I am parsing the param properly.

Upvotes: 0

Views: 182

Answers (1)

Emoyaki
Emoyaki

Reputation: 105

For people that are searching for an answer: Since Google updated its API, it's a requirement to parse readMask as well:

 $mybusinessbusinessinformationService = new Google\Service\MyBusinessBusinessInformation($client);
$params = array('readMask'=> "title,name");               
$locations = $mybusinessbusinessinformationService->accounts_locations->listAccountsLocations($getAccountName,$params);

var_dump($locations);

You can find the mask parameters here: https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations

Upvotes: 2

Related Questions