api_key = $apiKey; } /** * Create new order * @param int $service Service ID * @param string $link Target link * @param int $quantity Quantity * @return object Response with order ID */ public function createOrder(int $service, string $link, int $quantity): object { return $this->request('v1/order/create', 'GET', [ 'service' => $service, 'link' => $link, 'quantity' => $quantity, ]); } /** * Cancel order * @param int $orderId Order ID to cancel * @return object Response with status */ public function cancelOrder(int $orderId): object { return $this->request('v1/order/cancel', 'GET', [ 'id' => $orderId, ]); } /** * Refill order * @param int $orderId Order ID to refill * @return object Response with status */ public function refillOrder(int $orderId): object { return $this->request('v1/order/refill', 'GET', [ 'id' => $orderId, ]); } /** * Get order status * @param int $orderId Order ID * @return object Order status data */ public function getOrderStatus(int $orderId): object { return $this->request('v1/order/view', 'GET', [ 'order' => $orderId, ]); } /** * Get multiple orders status * @param array $orderIds Array of order IDs (max 100) * @return object Statuses of requested orders */ public function getMultiOrderStatus(array $orderIds): object { return $this->request('v1/order/view', 'GET', [ 'orders' => implode(',', array_slice($orderIds, 0, 100)), ]); } /** * Get all services * @return array List of available services */ public function getServices(): array { return $this->request('v1/service/index'); } /** * Get user balance * @return object Balance information */ public function getBalance(): object { return $this->request('v1/user/balance'); } /** * Make API request * @param string $endpoint API endpoint * @param array $getData Request GET parameters * @param array $postData Request POST parameters * @return mixed Decoded response */ private function request(string $endpoint, string $method = 'GET', array $data = []) { $url = $this->api_url . '?r=' . $endpoint; $data['key'] = $this->api_key; if ($method === 'GET') { $url = $url . '&' . http_build_query($data); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); if ($method === 'POST') { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json' ]); $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('API request failed: ' . curl_error($ch)); } curl_close($ch); $parsedResult = json_decode($result); if ($parsedResult === null) { throw new Exception('Json parse error: ' . $result); } return $parsedResult; } } // Примеры использования: $api = new SexySmmApi('7ffbce8a7c07840f17da62db3ad77a27'); // Получение списка услуг $services = $api->getServices(); // Получение баланса $balance = $api->getBalance(); // Создание заказа $newOrder = $api->createOrder( $services[0]->service, // ID услуги 'https://instagram.com/p/EXAMPLE', // Ссылка на пост 100 // Количество ); $antherOrder = $api->createOrder( $services[1]->service, // ID услуги 'https://instagram.com/p/EXAMPLE', // Ссылка на пост 200 // Количество ); // Получение статуса заказа $orderStatus = $api->getOrderStatus($newOrder->order); // Получение статусов нескольких заказов $multiStatus = $api->getMultiOrderStatus([$newOrder->order, $antherOrder->order]); // Запрос на докрутку $refillResult = $api->refillOrder($newOrder->order); // Отмена заказа $cancelResult = $api->cancelOrder($antherOrder->order);