API key. */ class Api { /** API URL */ public $api_url = 'https://YOUR-PANEL-DOMAIN/api/v2'; /** Your API key */ public $api_key = 'YOUR_API_KEY'; /** Add order */ public function order($data) { $post = array_merge(['key' => $this->api_key, 'action' => 'add'], $data); return json_decode($this->connect($post)); } /** Get order status */ public function status($order_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'status', 'order' => $order_id, ])); } /** Get multiple orders status (up to 100 ids) */ public function multiStatus($order_ids) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'status', 'orders' => implode(',', (array)$order_ids), ])); } /** Get services */ public function services() { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'services', ])); } /** Create refill */ public function refill($order_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'refill', 'order' => $order_id, ])); } /** Get refill status */ public function refillStatus($refill_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'refill_status', 'refill' => $refill_id, ])); } /** Cancel orders */ public function cancel($order_ids) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'cancel', 'orders' => implode(',', (array)$order_ids), ])); } /** Get balance */ public function balance() { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'balance', ])); } private function connect($post) { $ch = curl_init($this->api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); $result = curl_exec($ch); if (curl_errno($ch) != 0 && empty($result)) { $result = false; } curl_close($ch); return $result; } } // Examples $api = new Api(); $services = $api->services(); // Return all services $balance = $api->balance(); // Return user balance // Add order $order = $api->order(['service' => 1, 'link' => 'http://example.com/test', 'quantity' => 100]); // Default $order = $api->order(['service' => 1, 'link' => 'http://example.com/test', 'comments' => "good pic\ngreat photo"]); // Custom comments $status = $api->status($order->order); // Return status, charge, remains, start count, currency $statuses = $api->multiStatus([1, 2, 3]); // Return orders status, charge, remains, start count, currency $refill = $api->refill($order->order); // Create refill $cancel = $api->cancel([1, 2]); // Cancel orders