2017 © Pedro Peláez
 

library laravel-search-console

A Laravel package to retrieve data from Google Search Console

image

schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  • Saturday, July 28, 2018
  • by schulzefelix
  • Repository
  • 1 Watchers
  • 3 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 44 % Grown

The README.md

Laravel Search Console

Latest Version ![Software License][ico-license] Build Status Quality Score StyleCI Latest Version on Packagist ![Total Downloads][ico-downloads], (*1)

Using this package you can easily retrieve data from Google Search Console API., (*2)

Here are a few examples of the provided methods:, (*3)

use SearchConsole;

//list all available sites for that token
SearchConsole::setAccessToken($token)->listSites();

//get site details (permissionLevel) for specific site
SearchConsole::setAccessToken($token)->getSite('http://blog.example.com/');

Install

This package can be installed through Composer., (*4)

``` bash $ composer require schulzefelix/laravel-search-console, (*5)


Optionally, you can publish the config file of this package with this command: ``` bash php artisan vendor:publish --provider="SchulzeFelix\SearchConsole\SearchConsoleServiceProvider"

The following config file will be published in config/search-console.php, (*6)

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication
    |--------------------------------------------------------------------------
    | Google offers access via OAuth client IDs or service accounts.
    | For more information see: https://developers.google.com/identity/protocols/OAuth2
    |
    | Supported: "oauth", "oauth_json", "service_account",
    */

    'auth_type' => env('GOOGLE_AUTH_TYPE', 'oauth'),

    /*
    |--------------------------------------------------------------------------
    | Application Credentials
    |--------------------------------------------------------------------------
    |
    | https://developers.google.com/api-client-library/php/auth/service-accounts#creatinganaccount
    */

    'connections' => [

        'oauth' => [
            'client_id' => env('GOOGLE_CLIENT_ID'),
            'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        ],

        'oauth_json' => [
            'auth_config' => storage_path('app/searchconsole/oauth-account-credentials.json'),
        ],

        'service_account' => [
            'application_credentials' => storage_path('app/searchconsole/service-account-credentials.json'),
        ],

    ],

    /*
     |--------------------------------------------------------------------------
     | Cache Settings
     |--------------------------------------------------------------------------
     | Here you may configure the "store" that the underlying Google_Client will
     | use to store it's data.  You may also add extra parameters that will
     | be passed on setCacheConfig (see docs for google-api-php-client).
     |
     | Optional parameters: "lifetime", "prefix"
     */

    'cache' => [
        'store' => 'file',
    ],

    /*
    |--------------------------------------------------------------------------
    | Application Name
    |--------------------------------------------------------------------------
    */

    'application_name' => env('SEARCH_CONSOLE_APPLICATION_NAME', 'GSC Agent'),
];

Usage

Here are two basic example to retrieve all sites and an export for search analytics data., (*7)

List Sites

$sites = SearchConsole::setAccessToken($token)->listSites();

Search Analytics

use SearchConsole;
use SchulzeFelix\SearchConsole\Period;

    $data = SearchConsole::setAccessToken($token)->setQuotaUser('uniqueQuotaUserString')
        ->searchAnalyticsQuery(
            'https://www.example.com/',
            Period::create(Carbon::now()->subDays(30), Carbon::now()->subDays(2)),
            ['query', 'page', 'country', 'device', 'date'],
            [['dimension' => 'query', 'operator' => 'notContains', 'expression' => 'cheesecake']],
            1000,
            'web',
            'all',
            'auto'
        );

Provided methos

Retrieve One Site

public function public function getSite(string $siteUrl): array

Retrieve All Sites

public function public function listSites(): Collection

Retrieve Search Analytics Data

public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto'): Collection

Check Access Token

public function public function isAccessTokenExpired(): Bool

Provided fluent configuration

Set Access Token (Required)

$sites = SearchConsole::setAccessToken($token)->listSites();

Set Quota User

To avoid to the API limits, you can provide a unique string for the authenticated account., (*8)

More information: https://developers.google.com/webmaster-tools/search-console-api-original/v3/limits, (*9)

$sites = SearchConsole::setAccessToken($token)->setQuotaUser('uniqueQuotaUserString')->listSites();

Get Underlying Service

You can get access to the underlying Google_Service_Webmasters object:, (*10)

SearchConsole::getWebmastersService();

Change log

Please see CHANGELOG for more information what has changed recently., (*11)

Testing

bash $ vendor/bin/phpunit, (*12)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*13)

Security

If you discover any security related issues, please email github@schulze.co instead of using the issue tracker., (*14)

Credits

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

28/07 2018

dev-master

9999999-dev https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

27/04 2018

1.1.2

1.1.2.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

06/03 2018

1.1.1

1.1.1.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

06/03 2018

dev-analysis-86DW6W

dev-analysis-86DW6W https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

12/10 2017

1.1.0

1.1.0.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

06/10 2017

1.0.0

1.0.0.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

28/09 2017

dev-analysis-qxMowM

dev-analysis-qxMowM https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

07/09 2017

0.1.0

0.1.0.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools

27/07 2017

0.0.1

0.0.1.0 https://github.com/schulzefelix/laravel-search-console

A Laravel package to retrieve data from Google Search Console

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel google laravel-search-console search console webmaster tools