$apiKey, 'action' => 'services' ]; // Initialize cURL for service list $ch1 = curl_init($apiUrl); curl_setopt_array($ch1, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData1, CURLOPT_SSL_VERIFYPEER => false, // Set to true in production ]); $response1 = curl_exec($ch1); $httpCode1 = curl_getinfo($ch1, CURLINFO_HTTP_CODE); curl_close($ch1); if ($httpCode1 == 200) { $services = json_decode($response1, true); if (is_array($services)) { echo "Success! Found " . count($services) . " services.\n"; echo "First service: " . $services[0]['name'] . " (ID: " . $services[0]['service'] . ")\n"; } else { echo "Error decoding JSON: " . $response1 . "\n"; } } else { echo "HTTP Error: " . $httpCode1 . "\n"; echo "Response: " . $response1 . "\n"; } echo "\n" . str_repeat("-", 50) . "\n\n"; // ============================================ // EXAMPLE 2: CREATE A NEW ORDER // ============================================ echo "=== EXAMPLE 2: Creating a New Order ===\n\n"; $postData2 = [ 'key' => $apiKey, 'action' => 'add', 'service' => 1, // Service ID from the list above 'link' => 'https://instagram.com/p/example', // Target link 'quantity' => 100, // Desired quantity // Optional parameters: // 'runs' => 2, // 'interval' => 60 ]; $ch2 = curl_init($apiUrl); curl_setopt_array($ch2, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData2, CURLOPT_SSL_VERIFYPEER => false, ]); $response2 = curl_exec($ch2); $httpCode2 = curl_getinfo($ch2, CURLINFO_HTTP_CODE); curl_close($ch2); if ($httpCode2 == 200) { $orderResult = json_decode($response2, true); if (isset($orderResult['order'])) { echo "Order created successfully!\n"; echo "Order ID: " . $orderResult['order'] . "\n"; $lastOrderId = $orderResult['order']; // Save for next example } else { echo "API Error: " . $response2 . "\n"; } } else { echo "HTTP Error: " . $httpCode2 . "\n"; echo "Response: " . $response2 . "\n"; } echo "\n" . str_repeat("-", 50) . "\n\n"; // ============================================ // EXAMPLE 3: CHECK ORDER STATUS (Single) // ============================================ echo "=== EXAMPLE 3: Checking Single Order Status ===\n\n"; // Use the order ID from the previous example, or a test ID $orderIdToCheck = isset($lastOrderId) ? $lastOrderId : 23501; $postData3 = [ 'key' => $apiKey, 'action' => 'status', 'order' => $orderIdToCheck ]; $ch3 = curl_init($apiUrl); curl_setopt_array($ch3, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData3, CURLOPT_SSL_VERIFYPEER => false, ]); $response3 = curl_exec($ch3); $httpCode3 = curl_getinfo($ch3, CURLINFO_HTTP_CODE); curl_close($ch3); if ($httpCode3 == 200) { $statusResult = json_decode($response3, true); if (isset($statusResult['status'])) { echo "Order ID: " . $orderIdToCheck . "\n"; echo "Status: " . $statusResult['status'] . "\n"; echo "Amount Charged: " . (isset($statusResult['charge']) ? $statusResult['charge'] : 'N/A') . "\n"; echo "Currency: " . (isset($statusResult['currency']) ? $statusResult['currency'] : 'USD') . "\n"; } else { echo "API Error or Order Not Found: " . $response3 . "\n"; } } else { echo "HTTP Error: " . $httpCode3 . "\n"; echo "Response: " . $response3 . "\n"; } echo "\n" . str_repeat("-", 50) . "\n\n"; // ============================================ // EXAMPLE 4: CHECK MULTIPLE ORDER STATUSES // ============================================ echo "=== EXAMPLE 4: Checking Multiple Order Statuses ===\n\n"; $postData4 = [ 'key' => $apiKey, 'action' => 'status', 'orders' => '23501,23502,23503' // Comma-separated Order IDs ]; $ch4 = curl_init($apiUrl); curl_setopt_array($ch4, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData4, CURLOPT_SSL_VERIFYPEER => false, ]); $response4 = curl_exec($ch4); $httpCode4 = curl_getinfo($ch4, CURLINFO_HTTP_CODE); curl_close($ch4); if ($httpCode4 == 200) { $multiStatusResult = json_decode($response4, true); if (is_array($multiStatusResult)) { echo "Received status for " . count($multiStatusResult) . " order(s).\n"; foreach ($multiStatusResult as $id => $data) { if (isset($data['error'])) { echo " Order $id: ERROR - " . $data['error'] . "\n"; } else { echo " Order $id: " . $data['status'] . "\n"; } } } else { echo "API Error: " . $response4 . "\n"; } } else { echo "HTTP Error: " . $httpCode4 . "\n"; echo "Response: " . $response4 . "\n"; } echo "\n" . str_repeat("-", 50) . "\n\n"; // ============================================ // EXAMPLE 5: CHECK USER BALANCE // ============================================ echo "=== EXAMPLE 5: Checking User Balance ===\n\n"; $postData5 = [ 'key' => $apiKey, 'action' => 'balance' ]; $ch5 = curl_init($apiUrl); curl_setopt_array($ch5, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData5, CURLOPT_SSL_VERIFYPEER => false, ]); $response5 = curl_exec($ch5); $httpCode5 = curl_getinfo($ch5, CURLINFO_HTTP_CODE); curl_close($ch5); if ($httpCode5 == 200) { $balanceResult = json_decode($response5, true); if (isset($balanceResult['balance'])) { echo "Current Balance: " . $balanceResult['balance'] . "\n"; echo "Currency: " . $balanceResult['currency'] . "\n"; } else { echo "API Error: " . $response5 . "\n"; } } else { echo "HTTP Error: " . $httpCode5 . "\n"; echo "Response: " . $response5 . "\n"; } echo "\n" . str_repeat("-", 50) . "\n\n"; echo "=== All Examples Complete ===\n"; echo "Note: Remember to replace the placeholder API key with your real one.\n"; ?>