PHP code example of revolution / laravel-google-searchconsole

1. Go to this page and download the library: Download revolution/laravel-google-searchconsole 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/ */

    

revolution / laravel-google-searchconsole example snippets


    'client_id'        => env('GOOGLE_CLIENT_ID', ''),
    'client_secret'    => env('GOOGLE_CLIENT_SECRET', ''),
    'redirect_uri'     => env('GOOGLE_REDIRECT', ''),
    'scopes'           => [\Google\Service\Webmasters::WEBMASTERS],
    'access_type'      => 'offline',
    'approval_prompt'  => 'force',
    'prompt'           => 'consent', //"none", "consent", "select_account" default:none

    'google' => [
        'client_id'     => env('GOOGLE_CLIENT_ID', ''),
        'client_secret' => env('GOOGLE_CLIENT_SECRET', ''),
        'redirect'      => env('GOOGLE_REDIRECT', ''),
    ],

namespace App\Search;

use Revolution\Google\SearchConsole\Query\AbstractQuery;

class NewQuery extends AbstractQuery
{
    public function init(): void
    {
        $this->setStartDate(now()->subMonthWithoutOverflow()->toDateString());
        $this->setEndDate(now()->toDateString());
        $this->setDimensions(['query']);
        $this->setAggregationType(['auto']);
        $this->setRowLimit(100);
    }
}