class SimpleSubscriber implements SubscriberInterface (View source)

SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API access.

Requests are accessed using the Simple API access developer key.

Methods

__construct(array $config)

Create a new Simple plugin.

array
getEvents()

No description

onBefore(BeforeEvent $event)

Updates the request query with the developer key if auth is set to simple.

Details

__construct(array $config)

Create a new Simple plugin.

The configuration array expects one option

  • key: required, otherwise InvalidArgumentException is thrown

Parameters

array $config

Configuration array

array getEvents()

No description

Return Value

array

onBefore(BeforeEvent $event)

Updates the request query with the developer key if auth is set to simple.

use Google\Auth\Subscriber\SimpleSubscriber; use GuzzleHttp\Client;

$my_key = 'is not the same as yours'; $subscriber = new SimpleSubscriber(['key' => $my_key]);

$client = new Client([ 'base_url' => 'https://www.googleapis.com/discovery/v1/', 'defaults' => ['auth' => 'simple'] ]); $client->getEmitter()->attach($subscriber);

$res = $client->get('drive/v2/rest');

Parameters

BeforeEvent $event