Slicehost API Made Easy

Tim Barsness
October 14, 2009

I’ve been playing with the Slicehost API and ran accross PHP interface for the Slicehost API and am now sold on using PHP for the slicehost API.  Track multiple slices, multiple accounts if you like.  You can also launch slices or delete them as needed.  Here’s how to grab a bunch of info about your account:

include('slicemanager.php');

$api_key = '';  //Enter your API Key

$sm = new SliceManager($api_key);

echo "======== Slices ========\n";
foreach($sm->listSlices() as $slice)
{
	echo 'Name: '.$slice['name']."\n";
	echo 'Status: '.$slice['status']."\n";
	echo 'Bandwidth-in:    '.$slice['bw-in']."\n";
	echo 'Bandwidth-out:   '.$slice['bw-out']."\n";
	echo 'Bandwidth-total: '.((float)$slice['bw-in'] + (float)$slice['bw-out'])."\n";
	echo "\n";
}

echo "======== Zones ========\n";
foreach($sm->listZones() as $zone => $info)
{
	echo 'Zone: '.$zone."\n";
	echo 'ID: '.$info['id']."\n";
	echo 'TTL: '.$info['ttl']."\n";
	echo 'Active: '.$info['active']."\n";
	echo "\n";
}

Stay in Touch!

Stay in Touch!
Solutions Architecture

browse through our blog articles

Blog Archive