Skip to content

omnireach/search-console API reference

Floor
Provider · Omnireach
Version
1.x
Conformance suite
not wired
Verified for real
Verified in part
Licence
MIT
composer require omnireach/search-console:1.x-dev

Read from the package's own PHP files at the commit 25b5548dd42f: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnireach\SearchConsole

  • GoogleToken class

    A bearer token for a Google API: the one given, or one obtained for a service account - a JWT signed with its private key (RS256) exchanged at its token_uri (the OAuth 2.0 JWT bearer grant, RFC 7523) - and kept until a minute before it expires.

    4 methods

  • SearchConsoleFactory class

    Google Search Console, from its options:

    5 options · 1 method · 1 constant

  • SearchConsoleProvider class

    The Search Console API (https://developers.google.com/webmaster-tools): POST sites/{site}/searchAnalytics/query - dimensions, "equals" filters, pages of rows (startRow, rowLimit up to 25,000) - with a bearer token.

    5 methods

Omnireach\SearchConsole

GoogleToken class

final class GoogleToken GoogleToken.php:18

A bearer token for a Google API: the one given, or one obtained for a service account - a JWT signed with its private key (RS256) exchanged at its token_uri (the OAuth 2.0 JWT bearer grant, RFC 7523) - and kept until a minute before it expires.

The same class lives in omnireach/search-console and omnireach/ga4: two providers, one grant, no shared package for forty lines.

GoogleToken::__construct()

public function __construct(readonly JsonApi $api, readonly string $scope, readonly ?array $serviceAccount = null, ?string $token = null, readonly ?\Closure $clock = null)
$serviceAccount

the service account's JSON key, decoded (client_email, private_key, token_uri)

$clock

the present as a UNIX time (a test's); time() when null

GoogleToken::credentials()

public static function credentials(string $jsonOrPath): array

A service account's key: its JSON, or the path of its file.

GoogleToken::get()

public function get(): string

GoogleToken::assertion()

public function assertion(int $now): string

The signed JWT the token is asked with.

SearchConsoleFactory class

final class SearchConsoleFactory extends ProviderFactory SearchConsoleFactory.php:22

Google Search Console, from its options:

site the property: "sc-domain:example.org" (a domain property) or "https://example.org/" credentials a service account's JSON key, or the path of its file - the account added as a user of the property (Search Console, Settings, Users and permissions); or: access_token a token with the webmasters.readonly scope, obtained elsewhere data_state "final" (the default: complete days only) or "all" (the last days, provisional) url https://searchconsole.googleapis.com/webmasters/v3

Options

OptionDefault
credentials''
access_token''
data_state'final'
url'https://searchconsole.googleapis.com/webmasters/v3'
siterequired
const SCOPE = 'https://www.googleapis.com/auth/webmasters.readonly'

SearchConsoleFactory::__construct()

public function __construct(readonly ?HttpClientInterface $http = null)

SearchConsoleProvider class

final class SearchConsoleProvider implements SearchPerformanceInterface SearchConsoleProvider.php:19

The Search Console API (https://developers.google.com/webmaster-tools): POST sites/{site}/searchAnalytics/query - dimensions, "equals" filters, pages of rows (startRow, rowLimit up to 25,000) - with a bearer token.

SearchConsoleProvider::__construct()

public function __construct(readonly JsonApi $api, readonly GoogleToken $token, readonly string $site, readonly string $dataState = 'final', readonly string $url = 'https://searchconsole.googleapis.com/webmasters/v3')

SearchConsoleProvider::getName()

public function getName(): string

SearchConsoleProvider::getTitle()

public function getTitle(): string

SearchConsoleProvider::capabilities()

public function capabilities(): Capabilities

SearchConsoleProvider::searchPerformance()

public function searchPerformance(ReachQuery $query): Report