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

Using accounts.locations.list with PHP client

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

Hi all!

 

I'd really appreciate some help with a little problem I'm having.

 

I have been granted access to the My Business API and have been trying to get the listAccountsLocations function working.

This is part of the code I have:

$gmb = new Google_Service_MyBusiness($client);

print_r($gmb->accounts_locations->listAccountsLocations('ACC_NAME'));

print_r($gmb->accounts->listAccounts());

The listAccounts function works totally fine and shows me the expected results.

However, when trying to use the listAccountsLocations function I get a 404 error.

 

Could anyone offer a suggestion on what I'm doing wrong?

 

Thanks

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Alister B
March 2017

Using accounts.locations.list with PHP client

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Hello, I have a working example which is like this:

 

$gmbService = new Google_Service_MyBusiness($client);
$results = $gmbService->accounts->listAccounts();

$location = $gmbService->accounts_locations->listAccountsLocations($results['modelData']['accounts']['0']['name']);

 

which lists all locations for the account with that name. You can also just do this:

$location = $gmbService->accounts_locations->listAccountsLocations('accounts/XXXXXXXXXX');

 

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Alister B
March 2017

Using accounts.locations.list with PHP client

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Hello, I have a working example which is like this:

 

$gmbService = new Google_Service_MyBusiness($client);
$results = $gmbService->accounts->listAccounts();

$location = $gmbService->accounts_locations->listAccountsLocations($results['modelData']['accounts']['0']['name']);

 

which lists all locations for the account with that name. You can also just do this:

$location = $gmbService->accounts_locations->listAccountsLocations('accounts/XXXXXXXXXX');

 

Using accounts.locations.list with PHP client

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Ah!

Thank you @Luau D, I was missing the 'accounts/' part of the account name.

Re: Using accounts.locations.list with PHP client

Google Employee
# 4
Google Employee

Hi @Alister B,

 

For future reference, since the PHP client library doesn’t currently support the display of detailed error messages, so I suggest you follow the Make a simple HTTP request step-by-step guide on the Google Developers site and try use the OAuth 2.0 Playground to step through the auth flow, and examine the HTTP request/response at each step. This usually helps pinpoint where an application is passing the incorrect info.

 

Thanks,

Shalini

Using accounts.locations.list with PHP client

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Thanks @Shalini S, I'll give that a try.

Using accounts.locations.list with PHP client

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi @Shalini S,  are there docs on how to make a more complex request like a location->create() in the OAuth Playground? I can capture arguments and payloads prior to the call but how do I translate that into the playground. Json?

Re: Using accounts.locations.list with PHP client

Google Employee
# 7
Google Employee

Hi @ALEX C

 

Yes, please follow the Make a simple HTTP request step-by-step guide on the Google Developers site and let us if you are still unable to get your all locations using the OAuth 2.0 Playground?

 

You can use locations.create method to create a new location via the GMB API in OAuth playground.

 

Thanks,

The Google My Business API team