$apiKey, 'action' => 'services', ]; $ch = curl_init($apiUrl); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($payload), CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => ['Accept: application/json'], ]); $response = curl_exec($ch); if ($response === false) { throw new RuntimeException(curl_error($ch)); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); header('Content-Type: application/json; charset=utf-8'); echo json_encode([ 'http_code' => $httpCode, 'response' => json_decode($response, true) ?? $response, ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);