dev-master
9999999-dev https://github.com/nafresne/guzzle-ovh-pluginGuzzle plugin to manage OVH authentication
MIT
The Requires
- php >=5.4
The Development Requires
plugin api authentication rest guzzle ovh
Wallogit.com
2017 © Pedro Peláez
Guzzle plugin to manage OVH authentication
Guzzle 4 Plugin to use OVH API, (*2)
More informations on OVH API: https://api.ovh.com/, (*3)
# Install Composer curl -sS https://getcomposer.org/installer | php # Add the plugin as a dependency php composer.phar require nafresne/guzzle-ovh-plugin:dev-master
After installing, you need to require Composer's autoloader:, (*4)
require 'vendor/autoload.php';
require 'vendor/autoload.php';
use Nafresne\GuzzleHttp\OvhClient;
use Nafresne\GuzzleHttp\Subscriber\OvhSubscriber;
//Configuration
$config = array(
'application_key' => 'ApplicationKey',
'application_secret' => 'ApplicationSecret',
'consumer_key' => 'ConsumerKey'
);
// Create a Guzzle client
$client new OvhClient(['base_url' => 'https://eu.api.ovh.com/1.0/, 'time_url' => 'auth/time');
// and add it the plugin
$client->getEmitter()->attach(new OvhSubscriber($config));
// Now the plugin will add the correct OVH headers to your guzzle request
$response = $client->get('/data')->send();
parameters:
ovh.baseurl: "https://eu.api.ovh.com/1.0/"
ovh.timeurl: "auth/time"
ovh.config:
application_key: ApplicationKey
application_secret: ApplicationSecret
consumer_key: ConsumerKey
services:
guzzle.ovh.client:
class: Nafresne\GuzzleHttp\OvhClient
arguments:
- { base_url: %ovh.baseurl%, time_url: %ovh.timeurl%, emitter: @guzzle.ovh.emitter }
guzzle.ovh.emitter:
class: GuzzleHttp\Event\Emitter
calls:
- [attach, [@guzzle.ovh.subscriber]]
guzzle.ovh.subscriber:
class: Nafresne\GuzzleHttp\Subscriber\OvhSubscriber
arguments: [%ovh.config%]
$client = $this->container->get('guzzle.ovh.client');
$response = $client->get('hosting/web');
$body = $response->getBody();
composer install && vendor/bin/phpunit
This plugin is licensed under the MIT License, (*5)
Guzzle plugin to manage OVH authentication
MIT
plugin api authentication rest guzzle ovh