call(['action' => 'services']); } /** Новый заказ. $data: service, link, quantity (+ runs, interval для drip-feed; comments для своих комментариев) */ public function order(array $data) { return $this->call(array_merge(['action' => 'add'], $data)); } /** Статус одного заказа */ public function status($order_id) { return $this->call(['action' => 'status', 'order' => $order_id]); } /** Статус нескольких заказов (до 100 id через запятую) */ public function multiStatus(array $order_ids) { return $this->call(['action' => 'status', 'orders' => implode(',', $order_ids)]); } /** Баланс */ public function balance() { return $this->call(['action' => 'balance']); } private function call(array $post) { $post['key'] = $this->api_key; $ch = curl_init($this->api_url); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_USERAGENT => 'SMMGramApi/2.0 (PHP)', ]); $result = curl_exec($ch); if ($result === false) { $error = curl_error($ch); curl_close($ch); return (object) ['error' => $error]; } curl_close($ch); return json_decode($result); } } // Примеры $api = new SMMGramApi(); $services = $api->services(); // список услуг $balance = $api->balance(); // баланс $order = $api->order([ // обычный заказ 'service' => 1, 'link' => 'https://t.me/channel', 'quantity' => 100, ]); $order = $api->order([ // drip-feed: 10 запусков раз в 60 минут 'service' => 1, 'link' => 'https://t.me/channel', 'quantity' => 100, 'runs' => 10, 'interval' => 60, ]); $order = $api->order([ // свои комментарии, каждый с новой строки 'service' => 1, 'link' => 'https://t.me/channel/15', 'comments' => "Отличный пост\nСпасибо!", ]); $status = $api->status($order->order); // статус заказа $statuses = $api->multiStatus([1, 2, 3]); // статусы нескольких заказов