PHP code example of bronhy / google-my-business-php-client
1. Go to this page and download the library: Download bronhy/google-my-business-php-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bronhy / google-my-business-php-client example snippets
# HelloController.php
/**
* @Route("/hello/world") name="hello_world" methods=("GET")
*
* @param Google_Service_MyBusiness $myBusiness
*
* @return JsonResponse
*/
public function helloWorld(Google_Service_MyBusiness $myBusiness)
{
// some logic
return JsonResponse(['HelloWorld']);
}
# src/index.php
Google_Client();
$client->useApplicationDefaultCredentials();
// set the service account json file location manually
$client->setAuthConfig(__DIR__ . '/Data/service_account.json');
$client->setApplicationName("_Your_app_name_here_");
// set the scope to access GMBs
$client->setScopes([
"https://www.googleapis.com/auth/business.manage"
]);
// if you have not enabled/ have access to GMB API you need to request it directly with Google and enable it through the project's API explorer; search for "Google My Business API"