whoami7 - Manager
:
/
home
/
simspala
/
yoursimzone.com
/
Upload File:
files >> /home/simspala/yoursimzone.com/test.php
<?php // =============================== // PARROTICA API — Send Message (fixed) // =============================== $apiKey = "346253722935.ec88aea4081617845777365bd2375863"; // rotate for prod $userId = "1593"; // Correct endpoint per spec: POST /v1/message/{userId}/send $apiUrl = "https://api.parrotica.com/v1/message/$userId/send"; // Build payload (IDs must be integers) $payload = [ "content" => "Hello from my PHP app!", "senderId" => "DirectV", // must match an approved sender in Parrotica "scheduledAt" => null, // or an ISO-8601 UTC time if scheduling later "contactids" => [1001], // integers only "groupids" => [4004], // integers only "numbers" => ["+2349033333804"] ]; $body = json_encode($payload, JSON_UNESCAPED_SLASHES); // ---- cURL ---- $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $apiUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Accept: application/json", "x-api-key: $apiKey", "Content-Length: " . strlen($body), ], CURLOPT_TIMEOUT => 45, CURLOPT_CONNECTTIMEOUT => 20, CURLOPT_FOLLOWLOCATION => false, ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErr = curl_error($ch); curl_close($ch); // ---- Output / handling ---- echo "HTTP Code: $httpCode\n"; echo "Response:\n$response\n\n"; if ($curlErr) { echo "❌ cURL Error: $curlErr\n"; exit; } $data = json_decode($response, true); // Parrotica usually responds 200/201 on success — adjust if their spec says otherwise if (in_array($httpCode, [200, 201]) && is_array($data)) { // Some APIs use {status:"success"}; others return an object—log raw data just in case echo "✅ Likely success.\n"; if (isset($data['status'])) echo "Status: " . $data['status'] . "\n"; if (isset($data['message'])) echo "Message: " . $data['message'] . "\n"; if (isset($data['data'])) print_r($data['data']); } else { echo "⚠️ Failed. Details below:\n"; print_r($data); } // Optional: write a debug log file_put_contents(__DIR__ . "/parrotica_debug.log", date('c') . " [$httpCode] $response\n", FILE_APPEND);
Copyright ©2021 || Defacer Indonesia