1. Go to this page and download the library: Download arodygin/linode-api-php 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/ */
arodygin / linode-api-php example snippets
use Linode\LinodeApi;
use Linode\LinodeException;
use Linode\PaymentTerm;
// Your API key from the Linode profile.
$key = '...';
// Hardcode some IDs to make the example shorter.
// Normally you might want to use "Linode\AvailApi" class functions.
$datacenter = 3; // Fremont datacenter
$plan = 1; // we will use the cheapest plan
// Create new linode.
try {
$api = new LinodeApi($key);
$res = $api->create($datacenter, $plan, PaymentTerm::ONE_MONTH);
printf("Linode #%d has been created.\n", $res['LinodeID']);
}
catch (LinodeException $e) {
printf("Error #%d: %s.\n", $e->getCode(), $e->getMessage());
}
use Linode\Batch;
use Linode\LinodeApi;
use Linode\PaymentTerm;
// Your API key from the Linode profile.
$key = '...';
// Hardcode some IDs to make the example shorter.
// Normally you might want to use "Linode\AvailApi" class functions.
$datacenters = [2, 3, 4, 6]; // all four US datacenters
$plan = 1; // we will use the cheapest plan
// Create a batch.
$batch = new Batch($key);
// Create new linode on each of US datacenters.
$api = new LinodeApi($batch);
foreach ($datacenters as $datacenter) {
$api->create($datacenter, $plan, PaymentTerm::ONE_MONTH);
}
// Execute batch.
$results = $batch->execute();
foreach ($results as $res) {
printf("Linode #%d has been created.\n", $res['DATA']['LinodeID']);
}