PHP code example of ingress-it-solutions / laravel-google-my-business

1. Go to this page and download the library: Download ingress-it-solutions/laravel-google-my-business 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/ */

    

ingress-it-solutions / laravel-google-my-business example snippets


$httpHandler = HttpHandlerFactory::build($client);

// Add the header to the request
$request = $request->withHeader('X-GOOG-API-FORMAT-VERSION', '2');

IngressITSolutions\LaravelGoogleMyBusiness\GoogleMyBusinessServiceProvider::class,

'GoogleMyBusiness' => IngressITSolutions\LaravelGoogleMyBusiness\GoogleMyBusiness::class

use Google; // See: https://github.com/pulkitjalan/google-apiclient
use GoogleMyBusiness;

class MyExampleClass
{
  function authRedirect()
  {
    // Define the GMB scope
    $scopes = ['https://www.googleapis.com/auth/plus.business.manage'];

    // Define any configs that overrride the /config/google.php defaults from pulkitjalan/google-apiclient
    $googleConfig = array_merge(config('google'), [
      'scopes' => $scopes,
      'redirect_uri' =>
        config('app.callback_url') . '/callback/google/mybusiness',
    ]);

    // Generate an auth request URL
    $googleClient = new Google($googleConfig);
    $loginUrl = $googleClient->createAuthUrl();

    // Send user to Google for Authorisation
    return redirect()->away($loginUrl);
  }

  function getAccountName(Google $googleClient)
  {
    $gmb = new GoogleMyBusiness($googleClient);
    return $gmb->getAccountName();
  }
}