PHP code example of krystal / katapult
1. Go to this page and download the library: Download krystal/katapult 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/ */
krystal / katapult example snippets
use KatapultAPI\Core\ClientFactory;
$katapult = (new ClientFactory('your-katapult-api-token'))->create();
$virtualMachines = $katapult->getOrganizationVirtualMachines([
'organization[id]' => 'your-katapult-org-id',
])->getVirtualMachines();
foreach ($virtualMachines as $virtualMachine) {
echo $virtualMachine->getHostname() . PHP_EOL;
foreach ($virtualMachine->getIpAddresses() as $ipAddress) {
$prefix = filter_var($ipAddress->getAddress(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? 'ipv4' : 'ipv6';
echo ' ' . $prefix . ': ' . $ipAddress->getAddress() . PHP_EOL;
}
}