23501]. */ public function order($data) { return $this->connect(array_merge(['action' => 'add'], $data)); } /** Status of one order. Pass the id you got back from order(). */ public function status($order_id) { return $this->connect([ 'action' => 'status', 'order' => $order_id, ]); } /** Status of several orders at once. Pass an array of ids. */ public function multiStatus($order_ids) { return $this->connect([ 'action' => 'status', 'orders' => implode(',', (array) $order_ids), ]); } /** Every service, with its rate, min and max. */ public function services() { return $this->connect(['action' => 'services']); } /** Ask for a refill on a completed order. */ public function refill($order_id) { return $this->connect([ 'action' => 'refill', 'order' => $order_id, ]); } /** Where a refill request got to. */ public function refillStatus($refill_id) { return $this->connect([ 'action' => 'refill_status', 'refill' => $refill_id, ]); } /** Cancel orders. Pass an array of ids. */ public function cancel($order_ids) { return $this->connect([ 'action' => 'cancel', 'orders' => implode(',', (array) $order_ids), ]); } /** Your balance and currency. */ public function balance() { return $this->connect(['action' => 'balance']); } private function connect($post) { $post['key'] = $this->api_key; $ch = curl_init($this->api_url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'], CURLOPT_TIMEOUT => 30, /* Leave these on. Turning verification off to "make it work" hands your API key to anyone able to sit between you and the panel. */ CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, ]); $body = curl_exec($ch); $errno = curl_errno($ch); $error = curl_error($ch); curl_close($ch); if ($errno) { throw new RuntimeException("Could not reach the API: $error"); } $json = json_decode($body, true); if (!is_array($json)) { throw new RuntimeException("The API did not return JSON: $body"); } return $json; } } /* ---------------------------------------------------------------------- */ /* Examples */ /* ---------------------------------------------------------------------- */ $api = new SmmApi(); try { // What can I buy, and what does it cost? $services = $api->services(); // A plain order. $new = $api->order([ 'service' => 1, 'link' => 'https://example.com/your-post', 'quantity' => 100, ]); // A drip-feed order: 100 at a time, every 60 minutes, 10 times over. $drip = $api->order([ 'service' => 1, 'link' => 'https://example.com/your-post', 'quantity' => 100, 'runs' => 10, 'interval' => 60, ]); // An order that takes a comment list instead of a quantity. $comments = $api->order([ 'service' => 1, 'link' => 'https://example.com/your-post', 'comments' => "first comment\nsecond comment\nthird comment", ]); // Where did it get to? $status = $api->status($new['order']); // Several at once. $many = $api->multiStatus([$new['order'], $drip['order']]); // Dropped followers on a completed order. $refill = $api->refill($new['order']); $where = $api->refillStatus($refill['refill']); // Changed your mind, before it starts. $cancelled = $api->cancel([$drip['order']]); // What is left in the account. $balance = $api->balance(); print_r($balance); } catch (RuntimeException $e) { /* Log it. Do not print the message straight onto a page - it can contain the URL your key was sent to. */ error_log($e->getMessage()); }