diff --git a/README.md b/README.md index ef6dcdf..76bf865 100644 --- a/README.md +++ b/README.md @@ -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 +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? ------------------------------- @@ -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 diff --git a/src/Api.php b/src/Api.php index ba28784..6b8d067 100644 --- a/src/Api.php +++ b/src/Api.php @@ -128,6 +128,8 @@ class Api if (!isset($http_client)) { $http_client = new GClient(); + $http_client->setDefaultOption('timeout', 30); + $http_client->setDefaultOption('connect_timeout', 5); } $this->application_key = $application_key;