This commit is contained in:
lizandrogd
2026-01-13 02:12:18 -05:00
parent 0544e81463
commit ccea8adefa
7 changed files with 331 additions and 36 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* Script de debug para probar API de multimedia
*/
// URL del API
$apiUrl = 'http://localhost/whatsapp/api/send_media_message.php';
// Datos de prueba
$data = [
'recipient' => '573168950803',
'media_url' => 'http://localhost/whatsapp/uploads/test.jpg',
'media_type' => 'image',
'caption' => 'Test de imagen',
'filename' => 'test.jpg'
];
echo "=== TEST API MULTIMEDIA ===\n\n";
echo "URL: $apiUrl\n";
echo "Datos enviados:\n";
print_r($data);
echo "\n";
// Hacer petición
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
echo "=== RESPUESTA ===\n";
echo "HTTP Code: $httpCode\n";
echo "Content-Type: $contentType\n";
echo "\nRespuesta RAW:\n";
echo $response;
echo "\n\n";
// Intentar decodificar JSON
echo "=== DECODIFICACIÓN JSON ===\n";
$decoded = json_decode($response, true);
if ($decoded === null) {
echo "ERROR: No se pudo decodificar JSON\n";
echo "JSON Error: " . json_last_error_msg() . "\n";
echo "\nPrimeros 500 caracteres de la respuesta:\n";
echo substr($response, 0, 500) . "\n";
} else {
echo "JSON decodificado correctamente:\n";
print_r($decoded);
}
?>