2017 © Pedro Peláez
 

library google-search-console

Wrapper for google/apiclient to access and retrieve data from Google Search Console.

image

hkirsman/google-search-console

Wrapper for google/apiclient to access and retrieve data from Google Search Console.

  • Tuesday, September 6, 2016
  • by hkirsman
  • Repository
  • 0 Watchers
  • 6 Stars
  • 582 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 9 % Grown

The README.md

hkirsman/google-search-console

Wrapper for google/apiclient to access and retrieve data from Google Search Console using PHP. You can find this project in both https://packagist.org/packages/hkirsman/google-search-console and https://github.com/hkirsman/hkirsman-google-search-console, (*1)

Installation (using Composer)

Add hkirsman/google-search-console to your project:, (*2)

composer require hkirsman/google-search-console:dev-master

Get key from https://console.developers.google.com. There you have to create a project if you don't have it already, enable the 'Google Search Console API' and create 'Service account key' (json format). Add this keyfile to your project root or define custom path like this:, (*3)

$searchConsole = new SearchConsoleApi('/foo/bar/service-account.json');

instead of just, (*4)

$searchConsole = new SearchConsoleApi();

You'll also have to get Service account ID (XXXX@developer.gserviceaccount.com) and add it as user in the https://www.google.com/webmasters/tools/., (*5)

Example

Try this example file. Replace http://www.example.com/ with your url and also 'expression' => '/SUBPATH/',, (*6)

<?php

require_once 'vendor/autoload.php';

use HannesKirsman\GoogleSearchConsole\SearchConsoleApi;

$searchConsole = new SearchConsoleApi();
$options = SearchConsoleApi::getDefaultOptions();
$options['site_url'] = 'http://www.example.com/';
$options['start_date'] = date('Y-m-d', strtotime("-3 days"));;
$options['end_date'] = date('Y-m-d', strtotime("-3 days"));;
$options['setDimensionFilterGroups'] = array(
  'filters' => array (
    'dimension' => 'page',
    'operator' => 'contains',
    'expression' => '/SUBPATH/',
  ),
);

$rows = $searchConsole->getRows($options);
print_r($rows);

The Versions

06/09 2016

dev-master

9999999-dev

Wrapper for google/apiclient to access and retrieve data from Google Search Console.

  Sources   Download

The Requires

 

The Development Requires

by Hannes Kirsman