spotonlive / php-google-my-business

Google MyBusiness
Apache License 2.0
29 stars 25 forks source link

Please, add some example on usage #10

Closed nekromoff closed 5 years ago

nekromoff commented 5 years ago

I mean, I have experience with other Google APIs, but this has similar parametrization to GTM API and one can dump the main service to get classes and methods etc., but some basic how-to should be included.

nekromoff commented 5 years ago
// oauth2 code here to get a token etc., then proceed with a returned token
$client = $this->initializeClient($known_token, ['https://www.googleapis.com/auth/plus.business.manage']);
$service = new \Google_Service_MyBusiness($client);
// get GMB accounts
$accounts = $service->accounts->listAccounts()->getAccounts();
// get GMB account locations (for the first account)
$locations = $service->accounts_locations->listAccountsLocations($accounts[0]['name']);
// get posts for the selected location
$service->accounts_locations_localPosts->listAccountsLocationsLocalPosts($locations[0]['name'])
nekromoff commented 5 years ago

I'll be adding more tutorials here as I progress.

nikolajlovenhardt commented 5 years ago

Hi @nekromoff

You're welcome to open a PR. I'm closing this issue.