nafresne / guzzle-ovh-plugin
Guzzle plugin to manage OVH authentication
dev-master
2014-11-06 11:57 UTC
Requires
- php: >=5.4
Requires (Dev)
- guzzlehttp/guzzle: 4.*
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2025-03-25 05:22:09 UTC
README
#Guzzle OVH Plugin
Guzzle 4 Plugin to use OVH API
More informations on OVH API: https://api.ovh.com/
##Installation
###Install via composer
# 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:
require 'vendor/autoload.php';
##Basic usage
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();
##Symfony 2 usage
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();
##Tests
composer install && vendor/bin/phpunit
##License
This plugin is licensed under the MIT License