Skip to content

Commit

Permalink
Merge pull request #20 from VincentCasse/master
Browse files Browse the repository at this point in the history
Fix issues open on github

Signed-off-by: Jean-Tiare Le Bigot <jean-tiare.le-bigot@corp.ovh.com>
  • Loading branch information
yadutaf committed Dec 16, 2015
2 parents 3a8ce8a + d99c758 commit efd7703
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ foreach ($servers as $server) {

?>
```
How to customize HTTP client configuration?
-------------------------------------------

You can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests

```php
<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client;

// Informations about your application
$applicationKey = "your_app_key";
$applicationSecret = "your_app_secret";
$consumer_key = "your_consumer_key";

// Information about API and rights asked
$endpoint = 'ovh-eu';

$client = new Client();
$client->setDefaultOption('timeout', 1);
$client->setDefaultOption('headers', array('User-Agent' => 'api_client') );

// Get servers list
$conn = new Api( $applicationKey,
$applicationSecret,
$endpoint,
$consumer_key,
$client);
$webHosting = $conn->get('/hosting/web/');

foreach ($webHosting as $webHosting) {
echo "One of our web hosting: " . $webHosting . "\n";
```

How to build the documentation?
-------------------------------
Expand Down Expand Up @@ -215,7 +249,6 @@ Supported APIs
* Community support: https://community.runabove.com
* Console: https://api.runabove.com/console/
* Create application credentials: https://api.runabove.com/createApp/
* Create script credentials (all keys at once): https://api.runabove.com/createToken/

## Related links

Expand Down
2 changes: 2 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public function __construct(

if (!isset($http_client)) {
$http_client = new GClient();
$http_client->setDefaultOption('timeout', 30);
$http_client->setDefaultOption('connect_timeout', 5);
}

$this->application_key = $application_key;
Expand Down

0 comments on commit efd7703

Please sign in to comment.