services()); * print_r($api->add(['service' => 5, 'link' => 'https://instagram.com/username', 'quantity' => 1000])); * print_r($api->status(40321)); * print_r($api->multiStatus([40321, 40322])); * print_r($api->refill(40321)); * print_r($api->refillStatus(1204)); * print_r($api->cancel(40322)); * print_r($api->speedUp(40322)); * print_r($api->balance()); */ class PanelApi { public $url = 'https://leoprovider.com/api/v1'; private $key; public function __construct($key) { $this->key = $key; } /** Place an order: service, link, quantity – plus runs + interval (drip-feed), comments (custom comments) or speed (custom speed) */ public function add(array $data) { return $this->call(['action' => 'add'] + $data); } public function status($order) { return $this->call(['action' => 'status', 'order' => $order]); } public function multiStatus(array $orders) { return $this->call(['action' => 'status', 'orders' => implode(',', $orders)]); } public function services() { return $this->call(['action' => 'services']); } public function refill($order) { return $this->call(['action' => 'refill', 'order' => $order]); } public function multiRefill(array $orders) { return $this->call(['action' => 'refill', 'orders' => implode(',', $orders)]); } public function refillStatus($refill) { return $this->call(['action' => 'refill_status', 'refill' => $refill]); } public function multiRefillStatus(array $refills) { return $this->call(['action' => 'refill_status', 'refills' => implode(',', $refills)]); } public function cancel($order) { return $this->call(['action' => 'cancel', 'order' => $order]); } public function speedUp($order) { return $this->call(['action' => 'speed_up', 'order' => $order]); } public function balance() { return $this->call(['action' => 'balance']); } /** POST to the API and decode the JSON answer (an array with an "error" key when something went wrong) */ private function call(array $post) { $post['key'] = $this->key; $ch = curl_init($this->url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_USERAGENT => 'PanelApi/1.0 (+PHP)', ]); $body = curl_exec($ch); if ($body === false) { $err = curl_error($ch); curl_close($ch); return ['error' => 'Request failed: ' . $err]; } curl_close($ch); $json = json_decode($body, true); return is_array($json) ? $json : ['error' => 'Unexpected answer: ' . substr((string) $body, 0, 200)]; } }