PHP класс для работы с абузоустойчивым хостингом Inferno solution

Все вебмастера рано или поздно сталкиваются с проблемой поиска надежного хостинга. Я конечно же был не исключением. Перепробовав огромное количество предложений, остановился на реально качественном, с отличной тех.поддержкой и высоким аптаймом хостинге, предоставляемым компанией Inferno solution. Уже на протяжении довольно долгого времени сотрудничаю с ними и рекомендую всем своим клиентам.

Inferno solution предоставляет весь спектр хостинг услуг (в том числе и абузоустойчивый хостинг). Для посетителей моего блога доступны скидки:

Inferno solution предоставляет возможность управления хостингом, а также получение информации об услугах через API. Ниже делюсь PHP-классом.

class InfernoApi {
	private $email = ''; // Ваш email. Нужен для получения токена.
	private $pass = ''; // Ваш пароль от аккаунта. Нужен для получения токена.

	function __construct() {
		$this->url		= 'https://cp.inferno.name/api_client.php?action=';
		$this->cid		= false;
		$this->key		= false;
		$this->id		= false;
		$this->orderid	= false;
		$this->result	= array();
		$this->orders	= array();
	}

	public function GetApiKey(){
		if (empty($this->pass)) {
			die('Не указан пароль!');
		}
		if (empty($this->email)) {
			die('Не указан email!');
		}
		$this->result = file_get_contents($this->url . 'getApiKey&email=' . $this->email . '&pass=' . $this->pass);
		$this->JsonDecode();
		$this->cid = $this->result['cid'];
		$this->key = $this->result['key'];
		return $this->key;
	}

	private function JsonDecode() {
		$this->result = json_decode($this->result, true);
		$this->ServiceMessage();
	}

	public function Services() {
		$this->GetApiKey();
		$this->result = file_get_contents($this->url . 'services&cid=' . $this->cid . '&key=' . $this->key);
		$this->JsonDecode();
		return $this->result['services'];
	}

	public function GetService() {
		$this->GetApiKey();
		$this->id		= $this->Services()[0]['id'];
		$this->result	= file_get_contents($this->url . 'getService&cid=' . $this->cid . '&key=' . $this->key . '&serviceid=' . $this->id);
		$this->JsonDecode();
		return $this->result['service'];
	}

	public function Balance() {
		$this->GetApiKey();
		$this->result = file_get_contents($this->url . 'balance&cid=' . $this->cid . '&key=' . $this->key);
		$this->JsonDecode();
		return $this->result['balance'];
	}

	public function Orders() {
		$this->GetApiKey();
		$this->result = file_get_contents($this->url . 'orders&cid=' . $this->cid . '&key=' . $this->key);
		$this->JsonDecode();
		return $this->result;
	}

	public function GetInfo() {
		$this->GetApiKey();
		$this->Orders();
		foreach ($this->result['orders'] as $key => $value) {
			$this->result = file_get_contents($this->url . 'getinfo&cid=' . $this->cid . '&key=' . $this->key .'&orderid=' . $key);
			$this->JsonDecode();
			$this->orders[$key] = $this->result;
		}
		return $this->orders;
	}

	private function ServiceMessage() {
		if ($this->result['result'] !== 'success') {
			die($this->result['message']);
		}
	}
}

На данный момент доступно шесть функций:

  1. $InfernoApi->GetApiKey(); — получаем токен;
  2. $InfernoApi->Services(); — получить список подключенных услуг. На выходе получаем массив данных.
  3. $InfernoApi->GetService(); — получить более подробную информацию об услуге. На выходе получаем массив данных.
  4. $InfernoApi->Balance(); — получить доступный баланс. На выходе получаем массив данных.
  5. $InfernoApi->Orders(); — получить список заказов. На выходе получаем массив данных.
  6. $InfernoApi->GetInfo(); — получить информацию о VPS. На выходе получаем массив данных.

Вызов производим:

$InfernoApi = new InfernoApi();
$InfernoApi->GetApiKey();
$InfernoApi->Services();
$InfernoApi->GetService();
$InfernoApi->Balance();
$InfernoApi->Orders();
$InfernoApi->GetInfo();

В PHP-классе описаны не все возможности работы с API. В дальнейшем возможно я их дополню. Следите за обновлениями.