Actions

ElasticCreeper API

From CreeperHost Wiki

The Aries API makes creating minigame VPS's simple, below is a PHP example;

<?php
$api = new Aries("key", "secret");

//Start a Minigame VPS, any http url should be accepted, even with http auth, callback is called in the last 10 minutes of a minigame VPS, uuid is prepended.
$result = $api->exec('billing', 'spinupMinigame', array("game" => "custom", "ram" => 1, "time" => 1, "custom" => "http://www.creeperrepo.net/mg-templates/paintball.zip", "callback" => "http://someurl.com/callback.php?uuid="));
$uuid = $result->uuid;

//Adding another hour to an existing minigame at original pricing.
$result = $api->exec('billing', 'extendMinigame', array("uuid" => $uuid));

//Finding how long a minigame has left in seconds
$result = $api->exec('billing', 'timerMinigame', array("uuid" => $uuid));

//Get a list of all your running minigames
$result = $api->exec('billing', 'listMinigames');

//Stop a minigame VPS and receive a partial refund.
$result = $api->exec('billing', 'spindownMinigame', array("uuid" => $uuid));

//Start a proxy VPS, accepts http url as with minigames for your Bungee configuration
$result = $api->exec('billing', 'spinupProxy', array("ram" => 1, "time" => 1, "custom" => "http://www.creeperrepo.net/mg-templates/proxy.zip"));
$uuid = $result->uuid;

//Adding another hour to an existing proxy at original pricing.
$result = $api->exec('billing', 'extendProxy', array("uuid" => $uuid));

//Finding how long a proxy has left in seconds
$result = $api->exec('billing', 'timerProxy', array("uuid" => $uuid));

//Get a list of all your running proxies
$result = $api->exec('billing', 'listProxies');

//Stop a proxy VPS and receive a partial refund.
$result = $api->exec('billing', 'spindownProxy', array("uuid" => $uuid));

class Aries
{
	private $key;
	private $secret;
	function __construct($key, $secret)
	{
		$this->key = $key;
		$this->secret = $secret;
	}
	public function exec($service, $command, $data=array())
	{
		$url = 'https://api.creeperhost.net/'.$service."/".$command;
		$fields = array(
				'key' => urlencode($this->key),
				'secret' => urlencode($this->secret),
				'data' => json_encode($data)
		);
		$fields_string = "";
		foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
		rtrim($fields_string, '&');
		$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $url);
                //Uncomment if you have issues with SSL trust.
		//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($ch, CURLOPT_POST, count($fields));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);

                $data =curl_exec($ch);
		$result = json_decode(trim($data));
		curl_close($ch);

		return $result;
	}
}
?>

We have also ensured our Bungeecord plugin is open source, you can view the source at https://github.com/CreeperHost/ElasticCreeper