This commit is contained in:
lizandrogd
2026-01-21 14:23:38 -05:00
parent 65ea0b6f94
commit 9b35b990ab
2 changed files with 20 additions and 2 deletions
+12 -2
View File
@@ -133,7 +133,17 @@ try {
}
// Guardar respuesta en base de datos
if ($response && isset($response['conversations'][0]['id'])) {
// Aceptar tanto respuestas con 'conversations' como con 'messages'
$sentMessageId = null;
if ($response) {
if (isset($response['conversations'][0]['id'])) {
$sentMessageId = $response['conversations'][0]['id'];
} elseif (isset($response['messages'][0]['id'])) {
$sentMessageId = $response['messages'][0]['id'];
}
}
if ($response && $sentMessageId) {
error_log("send_media_message.php - Respuesta de WhatsApp exitosa: " . json_encode($response));
// Guardar en base de datos
@@ -149,7 +159,7 @@ try {
// Datos base para insertar
$conversationData = [
'user_id' => $user['id'],
'message_id' => $response['conversations'][0]['id'],
'message_id' => $sentMessageId,
'direction' => 'outgoing',
'message_type' => $mediaType,
'content' => $caption ?? $filename ?? '',
+8
View File
@@ -12,3 +12,11 @@
[2026-01-21 14:14:06] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[]
[2026-01-21 14:14:06] Graph API request to https://graph.facebook.com/v22.0/3932473397057815
[2026-01-21 14:14:07] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769023137&hash=ARlu_MCLx6NJCX8mxWXoqSxQ5jNO5lfqPV3wj5mAfq0qAQ
[2026-01-21 14:18:04] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[]
[2026-01-21 14:18:04] Graph API request to https://graph.facebook.com/v22.0/3932473397057815
[2026-01-21 14:18:05] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769023375&hash=ARkRlz4GA-ZtjKMzND1v40y0GdJXDGMW9qdByqTSi1CjbA
[2026-01-21 14:19:15] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D25882826341346950%26source%3Dwebhook%26ext%3D1769023432%26hash%3DARlok5rNWkPnc7hod-6QepmLdLTEgRuXGMZR_gmqKOXg4w&download=1 GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=25882826341346950&source=webhook&ext=1769023432&hash=ARlok5rNWkPnc7hod-6QepmLdLTEgRuXGMZR_gmqKOXg4w","download":"1"} POST:[]
[2026-01-21 14:19:15] Resolved media URL from Graph for mid 25882826341346950: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=25882826341346950&source=getMedia&ext=1769023445&hash=ARk0oFSQqHmwkHYglUJGyCEAtjWUyLiOf4kxqd_0l95FnA
[2026-01-21 14:19:26] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[]
[2026-01-21 14:19:26] Graph API request to https://graph.facebook.com/v22.0/3932473397057815
[2026-01-21 14:19:27] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769023457&hash=ARleg2ej-5Ypy9H7zywh-D2Y08uzbRBDLZvqCKFPAqdN4g