/api/v2 (shown on the API page) * API key: Account > API key * Every call is an HTTP POST; the answer is JSON. */ class Api { public $api_url = 'https://example.com/api/v2'; // replace with the API URL from the API page public $api_key = ''; // your API key /** Add an order. $data: service, link, quantity (+ runs, interval for drip-feed). */ public function order($data) { $post = array_merge(['key' => $this->api_key, 'action' => 'add'], $data); return json_decode($this->connect($post)); } /** Status of one order. */ public function status($order_id) { return json_decode($this->connect(['key' => $this->api_key, 'action' => 'status', 'order' => $order_id])); } /** Status of several orders (array of ids, at most 100). */ public function multiStatus($order_ids) { return json_decode($this->connect(['key' => $this->api_key, 'action' => 'status', 'orders' => implode(',', (array) $order_ids)])); } /** List of services. */ public function services() { return json_decode($this->connect(['key' => $this->api_key, 'action' => 'services'])); } /** Ask for a refill of an order. */ public function refill($order_id) { return json_decode($this->connect(['key' => $this->api_key, 'action' => 'refill', 'order' => $order_id])); } /** Status of a refill. */ public function refillStatus($refill_id) { return json_decode($this->connect(['key' => $this->api_key, 'action' => 'refill_status', 'refill' => $refill_id])); } /** Account 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_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, 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(); // all services $balance = $api->balance(); // your balance $order = $api->order(['service' => 1, 'link' => 'https://example.com/post', 'quantity' => 100]); // default $order = $api->order(['service' => 1, 'link' => 'https://example.com/post', 'quantity' => 100, 'runs' => 2, 'interval' => 5]); // drip-feed $status = $api->status($order->order); // one order $statuses = $api->multiStatus([1, 2, 3]); // several orders $refill = $api->refill($order->order); // refill $refillSt = $api->refillStatus($refill->refill);