Preventing Changes To My Google Business Listing using Laravel & the API

Recently, a malicious person had started making changes to my business’s Google Business listing. Google actually allows anyone to make edits anytime to any Business listing it seems. I had to keep changing it back multiple times a day. I requested access to Google My Business API and was granted access. I built an app last night that automatically detects changes and reverts the changes.

I also sent a cease & desist to the person making the changes and the attempts seem to have stopped. My app notifies me of attempts to change it and I haven’t seen anything lately.

The code was pretty basic if anyone needs to do something similar. I also set up a Scheduler to run this periodically every day and used Laravel Forge to push it to a $5 / mo AWS server.

If my code is helpful, please leave a comment! 🙂

$this->info('Starting to try to update Google Places');
$credentials = base_path('XXXXXXXXXXX.json');
$scope = '';
$ctGoogleLocationName = 'accounts/XXXXXXXXX/locations/XXXXXXXXXXXXXXX';

$ctIdealName = 'YOUR NAME HERE';
$ctIdealPhone = 'YOUR PHONE';
$ctIdealWebsiteUrl = '';


$redirect_uri = '<YOUR_REDIRECT_URI>';

$client = new Google_Client();

$client->setSubject('YOUR EMAIL ADDRESS');

$googleMyBusiness = new Google_Service_MyBusiness($client);

$this->info('About to check coalition on Google');
$coalition = $googleMyBusiness->accounts_locations->get($ctGoogleLocationName);

if($coalition->locationName != $ctIdealName ||
    $coalition->websiteUrl != $ctIdealWebsiteUrl ||
    $coalition->primaryPhone != $ctIdealPhone
    $this->info('Someone changed things! We will fix that');

    $changedToLocationName = $coalition->locationName;
    $changedToPrimaryPhone = $coalition->primaryPhone;
    $changedToWebsiteURL = $coalition->websiteUrl;

    $coalition->locationName = $ctIdealName;
    $coalition->primaryPhone = $ctIdealPhone;
    $coalition->websiteUrl = $ctIdealWebsiteUrl;
    $result = $googleMyBusiness->accounts_locations->patch($ctGoogleLocationName, $coalition);

    $data['changedToLocationName'] = $changedToLocationName;
    $data['changedToPrimaryPhone'] = $changedToPrimaryPhone;
    $data['changedToWebsiteURL'] = $changedToWebsiteURL;
    $data['ctIdealName'] = $ctIdealName;
    $data['ctIdealPhone'] = $ctIdealPhone;
    $data['ctIdealWebsiteUrl'] = $ctIdealWebsiteUrl;

    $this->info('Fixed. Send email notification.');

    Mail::send(['text' => 'emails.notify'], $data, function ($message) use ($data) {
        $message->from('YOUR EMAIL ADDRESS','Google Maps Updater' )
            ->to('Email','Google Maps Updater' )
            ->subject('Joels Google Updater Strikes Again!');

} else {
    $this->info('No changes. They fear our power!');


Published by

Joel Gross

Joel Gross is the CEO of Coalition Technologies.