1. Go to this page and download the library: Download proprietes-privees/ovh library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
proprietes-privees / ovh example snippets
/**
* # Instantiate. Visit https://api.ovh.com/createToken/index.cgi?GET=/me
* to get your credentials
*/
,
$consumer_key);
echo "Welcome " . $ovh->get('/me')['firstname'];
Ovh\Api;
session_start();
// Informations about your application
$applicationKey = "your_app_key";
$applicationSecret = "your_app_secret";
$redirection = "http://your_url.ovh";
// Information about API and rights asked
$endpoint = 'ovh-eu';
$rights = array( (object) [
'method' => 'GET',
'path' => '/me*'
]);
// Get credentials
$conn = new Api($applicationKey, $applicationSecret, $endpoint);
$credentials = $conn->requestCredentials($rights, $redirection);
// Save consumer key and redirect to authentication page
$_SESSION['consumer_key'] = $credentials["consumerKey"];
header('location: '. $credentials["validationUrl"]);
...
Ovh\Api;
// 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';
// Get servers list
$conn = new Api( $applicationKey,
$applicationSecret,
$endpoint,
$consumer_key);
$servers = $conn->get('/dedicated/server/');
foreach ($servers as $server) {
// Search servers inside SBG1
$details = $conn->get('/dedicated/server/'. $server);
if ($details['datacenter'] == 'sbg1') {
// Activate burst on server
$content = (object) array('status' => "active");
$conn->put('/dedicated/server/'. $server . '/burst', $content);
echo "We burst " . $server;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.