connect([ 'key' => $this->api_key, 'action' => 'balance' ])); } /** * Get services list */ public function services() { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'services' ])); } /** * Create new order */ public function order($data) { $post = array_merge([ 'key' => $this->api_key, 'action' => 'add' ], $data); return json_decode($this->connect($post)); } /** * Get order status */ public function status($order_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'status', 'order' => $order_id ])); } /** * Get multiple orders status */ public function multiStatus($order_ids) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'status', 'orders' => implode(',', (array)$order_ids) ])); } /** * Cancel order */ public function cancel($order_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'cancel', 'order' => $order_id ])); } /** * Request refill */ public function refill($order_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'refill', 'order' => $order_id ])); } /** * Get refill status */ public function refillStatus($refill_id) { return json_decode($this->connect([ 'key' => $this->api_key, 'action' => 'refill_status', 'refill' => $refill_id ])); } /** * Send API request */ private function connect($post) { $_post = []; if (is_array($post)) { foreach ($post as $name => $value) { $_post[] = $name . '=' . urlencode($value); } } $ch = curl_init($this->api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if (is_array($post)) { curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post)); } $result = curl_exec($ch); if (curl_errno($ch)) { return json_encode(['error' => curl_error($ch)]); } curl_close($ch); return $result; } } // ============================================ // USAGE EXAMPLES // ============================================ $api = new Api(); $api->api_url = 'https://yoursite.com/api/v2'; $api->api_key = 'YOUR_API_KEY'; // Get balance $balance = $api->balance(); echo "Balance: " . $balance->balance . " " . $balance->currency . "\n"; // Get services $services = $api->services(); foreach ($services as $service) { echo "Service #{$service->service}: {$service->name} - Rate: {$service->rate}\n"; } // Create order $order = $api->order([ 'service' => 1, 'link' => 'https://instagram.com/username', 'quantity' => 1000 ]); echo "Order ID: " . $order->order . "\n"; // Check order status $status = $api->status($order->order); echo "Status: " . $status->status . "\n"; // Cancel order $cancel = $api->cancel($order->order); if (isset($cancel->cancel)) { echo "Order cancelled successfully\n"; } // Request refill $refill = $api->refill($order->order); echo "Refill ID: " . $refill->refill . "\n"; // Check refill status $refillStatus = $api->refillStatus($refill->refill); echo "Refill Status: " . $refillStatus->status . "\n"; ?>