From 6ebf5c9a221f5881800fb6a9196b814d347c180a Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 28 Jan 2026 02:23:36 -0500 Subject: [PATCH] up --- Dockerfile | 12 +- Dockerfile.dev | 3 + FIX_PASTE_IMAGE_500.md | 57 ++ api/get_conversations.php | 4 + api/get_user_messages.php | 8 +- api/send_media_message.php | 40 +- api/send_media_message_debug.log | 147 +++++ api/upload_media.php | 50 +- api/version/media-url_debug.log | 157 +++++ assets/js/chat-common.js | 29 +- config/config.php | 12 +- conversations.php | 173 ++++-- cookies.txt | 5 + database/backup_production.sql | 584 ++++++++++++++++++ deploy-vps.sh | 394 ++++++++++++ docker-compose.dev.yml | 80 ++- docker-compose.prod.yml | 124 ++++ docker/entrypoint-dev.sh | 7 + docker/entrypoint.sh | 62 +- docker/fix-permissions.sh | 10 + docker/nginx/nginx.conf | 2 +- docker/nginx/ssl-prod.conf | 97 +++ docker/nginx/ssl.conf | 185 ++++++ docker/php/php-fpm.conf | 3 +- docker/php/php.ini | 1 + docker/scripts/generate-ssl.sh | 34 + fix_missing_local_thumb.php | 28 + migrations/20260127_add_whatsapp_media_id.sql | 7 + test_media_send.sh | 66 ++ test_session.php | 1 + 30 files changed, 2264 insertions(+), 118 deletions(-) create mode 100644 FIX_PASTE_IMAGE_500.md create mode 100644 cookies.txt create mode 100644 database/backup_production.sql create mode 100755 deploy-vps.sh create mode 100644 docker-compose.prod.yml create mode 100644 docker/fix-permissions.sh create mode 100644 docker/nginx/ssl-prod.conf create mode 100644 docker/nginx/ssl.conf create mode 100644 docker/scripts/generate-ssl.sh create mode 100644 fix_missing_local_thumb.php create mode 100644 migrations/20260127_add_whatsapp_media_id.sql create mode 100755 test_media_send.sh create mode 100644 test_session.php diff --git a/Dockerfile b/Dockerfile index 5bc05ed..9124f2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,9 @@ RUN apk add --no-cache \ libjpeg-turbo \ libpng \ mysql-client \ - redis + redis \ + ffmpeg \ + openssl # Copiar extensiones PHP desde builder COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ @@ -71,9 +73,10 @@ COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ # Copiar Composer desde builder COPY --from=composer:2 /usr/bin/composer /usr/bin/composer -# Crear usuario para la aplicación +# Crear usuario para la aplicación y configurar grupos RUN addgroup -g 1000 -S www && \ - adduser -u 1000 -S www -G www + adduser -u 1000 -S www -G www && \ + addgroup www nginx # Configurar PHP COPY docker/php/php.ini /usr/local/etc/php/conf.d/custom.ini @@ -94,6 +97,7 @@ RUN mkdir -p \ /var/www/html/uploads \ /var/log/supervisor \ /run/php \ + /etc/nginx/ssl \ && chown -R www:www /var/www/html \ && chown -R www:www /var/log/supervisor @@ -118,7 +122,7 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ CMD curl -f http://localhost/health.php || exit 1 # Exponer puertos -EXPOSE 80 9000 +EXPOSE 80 443 9000 # Script de inicio COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/Dockerfile.dev b/Dockerfile.dev index 1adb9b5..4942c40 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -14,6 +14,7 @@ RUN apk add --no-cache \ bash \ mysql-client \ redis \ + ffmpeg \ # Dependencias para XDebug y desarrollo autoconf \ g++ \ @@ -68,6 +69,8 @@ RUN { \ echo 'upload_max_filesize = 100M'; \ echo 'post_max_size = 100M'; \ echo 'date.timezone = America/Bogota'; \ + # Habilitar shell_exec para conversión de audio + echo 'disable_functions = '; \ # Desactivar OPcache para hot-reload echo 'opcache.enable = 0'; \ echo 'opcache.enable_cli = 0'; \ diff --git a/FIX_PASTE_IMAGE_500.md b/FIX_PASTE_IMAGE_500.md new file mode 100644 index 0000000..dbcd7f8 --- /dev/null +++ b/FIX_PASTE_IMAGE_500.md @@ -0,0 +1,57 @@ +## ✅ Problema del Error 500 Corregido + +### 🐛 Causa del Error: +Al pegar una imagen desde el portapapeles y enviarla, las peticiones `fetch` a los endpoints de API **NO estaban enviando las cookies de sesión**, causando que: +1. `upload_media.php` rechazara la petición → Error 401 +2. Nginx devolviera error 500 por fallo en PHP + +### 🔧 Solución Aplicada: + +Agregué `credentials: 'same-origin'` a ambos fetch en `sendMediaMessage()`: + +```javascript +// 1. Upload del archivo +const uploadResponse = await fetch('api/upload_media.php', { + method: 'POST', + credentials: 'same-origin', // ✅ Enviar cookies de sesión + body: formData +}); + +// 2. Envío del mensaje +const sendResponse = await fetch('api/send_media_message.php', { + method: 'POST', + credentials: 'same-origin', // ✅ Enviar cookies de sesión + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({...}) +}); +``` + +### 📋 Cómo Funciona Ahora: + +1. **Copias una imagen** (Ctrl+C o Cmd+C) +2. **Haces click en el input de mensaje** +3. **Pegas** (Ctrl+V o Cmd+V) +4. ✅ Aparece el preview de la imagen +5. ✅ Haces click en "Enviar" +6. ✅ Se sube el archivo con autenticación correcta +7. ✅ Se envía por WhatsApp +8. ✅ Aparece en la conversación + +### 🧪 Probar Ahora: + +1. Recarga la página: http://localhost:8080/conversations.php +2. Abre una conversación +3. Copia una imagen desde cualquier lugar +4. Haz click en el input de texto +5. Presiona Ctrl+V (o Cmd+V en Mac) +6. Debe aparecer el preview sin errores +7. Haz click en enviar +8. Debe enviarse correctamente + +### 📝 Nota Técnica: + +Por defecto, `fetch()` **NO envía cookies** a menos que especifiques: +- `credentials: 'same-origin'` → Envía cookies al mismo dominio +- `credentials: 'include'` → Envía cookies incluso en CORS + +El endpoint `upload_media.php` usa `requireAuthentication()` que verifica la sesión en cookies, por eso fallaba antes. diff --git a/api/get_conversations.php b/api/get_conversations.php index e35244c..33dde23 100644 --- a/api/get_conversations.php +++ b/api/get_conversations.php @@ -41,6 +41,8 @@ try { lm.content AS last_message, lm.direction AS direction, lm.message_type AS message_type, + lm.local_file AS last_local_file, + lm.local_thumb AS last_local_thumb, lm.created_at AS last_time, IFNULL(SUM(CASE WHEN c.direction = 'incoming' AND (c.is_read IS NULL OR c.is_read = 0) THEN 1 ELSE 0 END), 0) AS unread_count FROM users u @@ -86,6 +88,8 @@ try { 'last_time' => $conv['last_time'] ?? null, 'direction' => $conv['direction'] ?? 'incoming', 'message_type' => $conv['message_type'] ?? 'text', + 'last_local_file' => $conv['last_local_file'] ?? null, + 'last_local_thumb' => $conv['last_local_thumb'] ?? null, 'unread_count' => intval($conv['unread_count'] ?? 0), 'bot_enabled' => isset($conv['bot_enabled']) ? (bool)$conv['bot_enabled'] : true, 'on_hold' => isset($conv['on_hold']) ? (bool)$conv['on_hold'] : false, diff --git a/api/get_user_messages.php b/api/get_user_messages.php index 1e5df70..fbeea3b 100644 --- a/api/get_user_messages.php +++ b/api/get_user_messages.php @@ -59,6 +59,9 @@ try { c.content as content, c.message_id as message_id, c.media_url, + c.local_file, + c.filename, + c.mime_type, u.phone_number as user_phone, c.direction as direction, c.message_type as message_type, @@ -145,6 +148,10 @@ try { message_text as content, direction, message_type, + media_url, + local_file, + filename, + mime_type, status, created_at FROM conversations @@ -179,7 +186,6 @@ try { 'message_id' => $msg['message_id'] ?? null, 'media_url' => null, 'local_file' => $msg['local_file'] ?? null, - 'local_thumb' => $msg['local_thumb'] ?? null, 'media_url_external' => $external, 'filename' => $msg['filename'] ?? null, 'mime_type' => $msg['mime_type'] ?? null, diff --git a/api/send_media_message.php b/api/send_media_message.php index ac31e38..700e052 100644 --- a/api/send_media_message.php +++ b/api/send_media_message.php @@ -355,6 +355,39 @@ try { // Datos base para insertar // content: nombre de archivo o caption (nunca JSON) // media_url: ID de WhatsApp si está disponible, sino la URL original + // local_file: ruta relativa del archivo local si existe + // local_thumb: miniatura (por ahora usar mismo archivo para imágenes/videos) + + // Intentar determinar ruta local desde mediaUrl si no se definió antes + if (!isset($localFilePath) && $mediaUrl) { + try { + error_log("send_media_message.php - Intentando extraer local_file desde mediaUrl: " . $mediaUrl); + $parsedUrl = parse_url($mediaUrl); + $path = $parsedUrl['path'] ?? ''; + error_log("send_media_message.php - Path extraído: " . $path); + // Si la URL apunta a /uploads/, construir ruta local + if (strpos($path, '/uploads/') === 0) { + $uploadDir = __DIR__ . '/../uploads/'; + $filename_from_url = basename($path); + $testPath = $uploadDir . $filename_from_url; + error_log("send_media_message.php - Testeando archivo local: " . $testPath); + if (file_exists($testPath)) { + $localFilePath = $testPath; + error_log("send_media_message.php - ✅ Archivo local encontrado: " . $localFilePath); + } else { + error_log("send_media_message.php - ❌ Archivo local NO existe: " . $testPath); + } + } + } catch (Exception $e) { + error_log("send_media_message.php - Error parseando mediaUrl: " . $e->getMessage()); + } + } else { + error_log("send_media_message.php - localFilePath ya definido o mediaUrl vacío. localFilePath=" . (isset($localFilePath) ? $localFilePath : 'NULL') . ", mediaUrl=" . ($mediaUrl ?? 'NULL')); + } + + $localFileRelative = (isset($localFilePath) && file_exists($localFilePath)) ? str_replace(__DIR__ . '/../', '', $localFilePath) : null; + error_log("send_media_message.php - local_file relativo para BD: " . ($localFileRelative ?? 'NULL')); + $conversationData = [ 'user_id' => $user['id'], 'message_id' => $sentMessageId, @@ -363,6 +396,9 @@ try { 'content' => $content, 'media_url' => isset($uploaded_media_id) ? $uploaded_media_id : $mediaUrl, 'whatsapp_media_id' => $uploaded_media_id ?? null, + 'local_file' => $localFileRelative, + 'local_thumb' => ($mediaType === 'image' || $mediaType === 'video') ? $localFileRelative : null, + 'filename' => $filename ?? null, 'status' => 'sent', 'created_at' => date('Y-m-d H:i:s') ]; @@ -372,8 +408,10 @@ try { error_log(" - content: " . $content); error_log(" - media_url: " . ($conversationData['media_url'] ?? 'null')); error_log(" - whatsapp_media_id: " . ($conversationData['whatsapp_media_id'] ?? 'null')); + error_log(" - local_file: " . ($conversationData['local_file'] ?? 'null')); + error_log(" - local_thumb: " . ($conversationData['local_thumb'] ?? 'null')); error_log(" - media_type: " . $mediaType); - smm_log("Saving to DB - content: {$content}, media_url: " . ($conversationData['media_url'] ?? 'null')); + smm_log("Saving to DB - content: {$content}, media_url: " . ($conversationData['media_url'] ?? 'null') . ", local_file: " . ($conversationData['local_file'] ?? 'null') . ", local_thumb: " . ($conversationData['local_thumb'] ?? 'null')); try { $db->insert('conversations', $conversationData); diff --git a/api/send_media_message_debug.log b/api/send_media_message_debug.log index b6853bd..aa31c43 100644 --- a/api/send_media_message_debug.log +++ b/api/send_media_message_debug.log @@ -60,3 +60,150 @@ [2026-01-27 23:37:46] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNUU0NTQ4OURGNjYyQTkwQUI5AA=="}]} [2026-01-27 23:37:46] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNUU0NTQ4OURGNjYyQTkwQUI5AA=="}]} [2026-01-27 23:37:46] Saving to DB - content: survey.xlsx, media_url: 1374639530630158 +[2026-01-27 23:57:57] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799753b67d83.17233125.webm","media_type":"audio","caption":null,"filename":"record_1769576272869.webm"} +[2026-01-27 23:57:57] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799753b67d83.17233125.webm","media_type":"audio","caption":null,"filename":"record_1769576272869.webm"} +[2026-01-27 23:58:23] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_6979976dc5ecb2.11097928.xlsx","media_type":"document","caption":null,"filename":"survey.xlsx"} +[2026-01-27 23:58:23] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_6979976dc5ecb2.11097928.xlsx","media_type":"document","caption":null,"filename":"survey.xlsx"} +[2026-01-27 23:58:24] Upload result: {"id":"1873321179980667"} +[2026-01-27 23:58:24] Media ID obtained: 1873321179980667 +[2026-01-27 23:58:25] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMEE2QzEyRUE2NTAxRjJDODQwAA=="}]} +[2026-01-27 23:58:25] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMEE2QzEyRUE2NTAxRjJDODQwAA=="}]} +[2026-01-27 23:58:25] Saving to DB - content: survey.xlsx, media_url: 1873321179980667 +[2026-01-28 00:02:10] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799850802746.13854941.xlsx","media_type":"document","caption":null,"filename":"survey.xlsx"} +[2026-01-28 00:02:10] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799850802746.13854941.xlsx","media_type":"document","caption":null,"filename":"survey.xlsx"} +[2026-01-28 00:02:11] Upload result: {"id":"3100504000137603"} +[2026-01-28 00:02:11] Media ID obtained: 3100504000137603 +[2026-01-28 00:02:12] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQzQ3RDRCQTFERThERjM2QTgxAA=="}]} +[2026-01-28 00:02:12] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQzQ3RDRCQTFERThERjM2QTgxAA=="}]} +[2026-01-28 00:02:13] Saving to DB - content: survey.xlsx, media_url: 3100504000137603 +[2026-01-28 00:06:46] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799964926f58.72435045.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:06:46] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799964926f58.72435045.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:06:47] Upload result: {"id":"876668735219378"} +[2026-01-28 00:06:47] Media ID obtained: 876668735219378 +[2026-01-28 00:06:48] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQjlGNzZFODBDOTg3REQxRDZDAA=="}]} +[2026-01-28 00:06:48] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQjlGNzZFODBDOTg3REQxRDZDAA=="}]} +[2026-01-28 00:06:48] Saving to DB - content: media-url.jpg, media_url: 876668735219378 +[2026-01-28 00:08:44] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_697999dadb01c6.63157521.webm","media_type":"audio","caption":null,"filename":"record_1769576919723.webm"} +[2026-01-28 00:08:44] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_697999dadb01c6.63157521.webm","media_type":"audio","caption":null,"filename":"record_1769576919723.webm"} +[2026-01-28 00:14:59] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799b51530038.79115661.webm","media_type":"audio","caption":null,"filename":"record_1769576919723.webm"} +[2026-01-28 00:14:59] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799b51530038.79115661.webm","media_type":"audio","caption":null,"filename":"record_1769576919723.webm"} +[2026-01-28 00:15:54] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799b891e3c11.09600349.webm","media_type":"audio","caption":null,"filename":"record_1769577348725.webm"} +[2026-01-28 00:15:54] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799b891e3c11.09600349.webm","media_type":"audio","caption":null,"filename":"record_1769577348725.webm"} +[2026-01-28 00:17:05] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799bcfb8b031.52674216.webm","media_type":"audio","caption":null,"filename":"record_1769577421621.webm"} +[2026-01-28 00:17:05] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799bcfb8b031.52674216.webm","media_type":"audio","caption":null,"filename":"record_1769577421621.webm"} +[2026-01-28 00:20:06] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799c846ada20.81906873.webm","media_type":"audio","caption":null,"filename":"record_1769577601944.webm"} +[2026-01-28 00:20:06] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799c846ada20.81906873.webm","media_type":"audio","caption":null,"filename":"record_1769577601944.webm"} +[2026-01-28 00:21:20] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_69799ccf1bb225.76804681.webm","media_type":"audio","caption":null,"filename":"record_1769577675811.webm"} +[2026-01-28 00:21:20] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_69799ccf1bb225.76804681.webm","media_type":"audio","caption":null,"filename":"record_1769577675811.webm"} +[2026-01-28 00:24:06] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799d735ae469.91287547.ogg","media_type":"audio","caption":null,"filename":"record_1769577841134.webm"} +[2026-01-28 00:24:06] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799d735ae469.91287547.ogg","media_type":"audio","caption":null,"filename":"record_1769577841134.webm"} +[2026-01-28 00:24:07] Upload result: {"id":"903170332106418"} +[2026-01-28 00:24:07] Media ID obtained: 903170332106418 +[2026-01-28 00:24:09] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMUU0QTg1RUMwMkE0OTUyMDM2AA=="}]} +[2026-01-28 00:24:09] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMUU0QTg1RUMwMkE0OTUyMDM2AA=="}]} +[2026-01-28 00:24:09] Saving to DB - content: record_1769577841134.webm, media_url: 903170332106418 +[2026-01-28 00:27:47] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799e51c56f53.56537824.ogg","media_type":"audio","caption":null,"filename":"record_1769578062431.webm"} +[2026-01-28 00:27:47] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799e51c56f53.56537824.ogg","media_type":"audio","caption":null,"filename":"record_1769578062431.webm"} +[2026-01-28 00:27:48] Upload result: {"id":"2590254688014534"} +[2026-01-28 00:27:49] Media ID obtained: 2590254688014534 +[2026-01-28 00:27:49] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSNzkwNEYzQTdFQjkwNjQ1NzQ2AA=="}]} +[2026-01-28 00:27:49] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSNzkwNEYzQTdFQjkwNjQ1NzQ2AA=="}]} +[2026-01-28 00:27:50] Saving to DB - content: record_1769578062431.webm, media_url: 2590254688014534, local_file: uploads/media_69799e51c56f53.56537824.ogg +[2026-01-28 00:28:17] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799e6fd863b7.25583571.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:28:17] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799e6fd863b7.25583571.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:28:19] Upload result: {"id":"1375898793748917"} +[2026-01-28 00:28:19] Media ID obtained: 1375898793748917 +[2026-01-28 00:28:20] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSREYxQzNCQUZGMTA3NEVBN0I5AA=="}]} +[2026-01-28 00:28:20] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSREYxQzNCQUZGMTA3NEVBN0I5AA=="}]} +[2026-01-28 00:28:20] Saving to DB - content: media-url.jpg, media_url: 1375898793748917, local_file: uploads/media_69799e6fd863b7.25583571.jpg +[2026-01-28 00:30:22] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799eec0f6949.58637457.ogg","media_type":"audio","caption":null,"filename":"record_1769578217833.webm"} +[2026-01-28 00:30:22] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799eec0f6949.58637457.ogg","media_type":"audio","caption":null,"filename":"record_1769578217833.webm"} +[2026-01-28 00:30:23] Upload result: {"id":"882480841336174"} +[2026-01-28 00:30:23] Media ID obtained: 882480841336174 +[2026-01-28 00:30:24] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQTJBMDQwMTU1REUxRTBBMjI5AA=="}]} +[2026-01-28 00:30:24] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSQTJBMDQwMTU1REUxRTBBMjI5AA=="}]} +[2026-01-28 00:30:25] Saving to DB - content: record_1769578217833.webm, media_url: 882480841336174, local_file: uploads/media_69799eec0f6949.58637457.ogg +[2026-01-28 00:30:42] Raw input: {"recipient":"573168950803","media_url":"http://localhost:8080/uploads/media_69799f01048d32.15387881.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:30:42] Input decoded: {"recipient":"573168950803","media_url":"http:\/\/localhost:8080\/uploads\/media_69799f01048d32.15387881.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:30:44] Upload result: {"id":"2331604630676404"} +[2026-01-28 00:30:44] Media ID obtained: 2331604630676404 +[2026-01-28 00:30:44] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMzNCNjY1RUMyNTNCNEYzM0MwAA=="}]} +[2026-01-28 00:30:44] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573168950803","wa_id":"573168950803"}],"messages":[{"id":"wamid.HBgMNTczMTY4OTUwODAzFQIAERgSMzNCNjY1RUMyNTNCNEYzM0MwAA=="}]} +[2026-01-28 00:30:45] Saving to DB - content: media-url.jpg, media_url: 2331604630676404, local_file: uploads/media_69799f01048d32.15387881.jpg +[2026-01-28 00:31:45] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_69799f4019c754.81016370.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:31:45] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_69799f4019c754.81016370.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:31:47] Upload result: {"id":"1983961412192518"} +[2026-01-28 00:31:47] Media ID obtained: 1983961412192518 +[2026-01-28 00:31:48] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMDcxNUZFNDM1RDA2RkUyQzdGAA=="}]} +[2026-01-28 00:31:48] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMDcxNUZFNDM1RDA2RkUyQzdGAA=="}]} +[2026-01-28 00:31:48] Saving to DB - content: media-url.jpg, media_url: 1983961412192518, local_file: uploads/media_69799f4019c754.81016370.jpg +[2026-01-28 00:36:06] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a044c17079.66378227.ogg","media_type":"audio","caption":null,"filename":"record_1769578561744.webm"} +[2026-01-28 00:36:06] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a044c17079.66378227.ogg","media_type":"audio","caption":null,"filename":"record_1769578561744.webm"} +[2026-01-28 00:36:08] Upload result: {"id":"1551128883003002"} +[2026-01-28 00:36:08] Media ID obtained: 1551128883003002 +[2026-01-28 00:36:09] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNjFFMjczMzcwMjdGRjZEMTIyAA=="}]} +[2026-01-28 00:36:09] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNjFFMjczMzcwMjdGRjZEMTIyAA=="}]} +[2026-01-28 00:36:09] Saving to DB - content: record_1769578561744.webm, media_url: 1551128883003002, local_file: uploads/media_6979a044c17079.66378227.ogg, local_thumb: null +[2026-01-28 00:36:27] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a05981b3e3.76655176.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:36:27] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a05981b3e3.76655176.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:36:28] Upload result: {"id":"3480062748838248"} +[2026-01-28 00:36:28] Media ID obtained: 3480062748838248 +[2026-01-28 00:36:29] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRDM2RDA3ODc3RTBBMkU2OTRDAA=="}]} +[2026-01-28 00:36:29] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRDM2RDA3ODc3RTBBMkU2OTRDAA=="}]} +[2026-01-28 00:36:29] Saving to DB - content: media-url.jpg, media_url: 3480062748838248, local_file: uploads/media_6979a05981b3e3.76655176.jpg, local_thumb: uploads/media_6979a05981b3e3.76655176.jpg +[2026-01-28 00:47:02] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a2d407f105.12184484.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:47:02] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a2d407f105.12184484.jpg","media_type":"image","caption":null,"filename":"media-url.jpg"} +[2026-01-28 00:47:03] Upload result: {"id":"1953117515284557"} +[2026-01-28 00:47:03] Media ID obtained: 1953117515284557 +[2026-01-28 00:47:04] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRTNCREM3QzczMDkzRDA1MzJEAA=="}]} +[2026-01-28 00:47:04] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRTNCREM3QzczMDkzRDA1MzJEAA=="}]} +[2026-01-28 00:47:05] Saving to DB - content: media-url.jpg, media_url: 1953117515284557, local_file: uploads/media_6979a2d407f105.12184484.jpg, local_thumb: uploads/media_6979a2d407f105.12184484.jpg +[2026-01-28 00:51:04] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a3c5b236e8.04274010.ogg","media_type":"audio","caption":null,"filename":"record_1769579459198.webm"} +[2026-01-28 00:51:04] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a3c5b236e8.04274010.ogg","media_type":"audio","caption":null,"filename":"record_1769579459198.webm"} +[2026-01-28 00:51:05] Upload result: {"id":"893454973089562"} +[2026-01-28 00:51:05] Media ID obtained: 893454973089562 +[2026-01-28 00:51:06] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSQUYzRjE5QjE3OUE3OEIwQzlFAA=="}]} +[2026-01-28 00:51:06] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSQUYzRjE5QjE3OUE3OEIwQzlFAA=="}]} +[2026-01-28 00:51:06] Saving to DB - content: record_1769579459198.webm, media_url: 893454973089562, local_file: uploads/media_6979a3c5b236e8.04274010.ogg, local_thumb: null +[2026-01-28 00:54:15] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a485787858.65742730.ogg","media_type":"audio","caption":null,"filename":"record_1769579651401.webm"} +[2026-01-28 00:54:15] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a485787858.65742730.ogg","media_type":"audio","caption":null,"filename":"record_1769579651401.webm"} +[2026-01-28 00:54:17] Upload result: {"id":"759892943831328"} +[2026-01-28 00:54:17] Media ID obtained: 759892943831328 +[2026-01-28 00:54:18] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSODM5NEYwRDc2NjMxQUFEMzc2AA=="}]} +[2026-01-28 00:54:18] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSODM5NEYwRDc2NjMxQUFEMzc2AA=="}]} +[2026-01-28 00:54:18] Saving to DB - content: record_1769579651401.webm, media_url: 759892943831328, local_file: uploads/media_6979a485787858.65742730.ogg, local_thumb: null +[2026-01-28 00:59:18] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a5b4690f83.69035164.ogg","media_type":"audio","caption":null,"filename":"record_1769579952844.webm"} +[2026-01-28 00:59:18] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a5b4690f83.69035164.ogg","media_type":"audio","caption":null,"filename":"record_1769579952844.webm"} +[2026-01-28 00:59:19] Upload result: {"id":"1334972502008596"} +[2026-01-28 00:59:19] Media ID obtained: 1334972502008596 +[2026-01-28 00:59:20] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRTgyNEZEN0EwOTgzODI3RTlBAA=="}]} +[2026-01-28 00:59:20] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSRTgyNEZEN0EwOTgzODI3RTlBAA=="}]} +[2026-01-28 00:59:21] Saving to DB - content: record_1769579952844.webm, media_url: 1334972502008596, local_file: uploads/media_6979a5b4690f83.69035164.ogg, local_thumb: null +[2026-01-28 01:16:06] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979a9a3d39a72.62917885.ogg","media_type":"audio","caption":null,"filename":"record_1769580961330.webm"} +[2026-01-28 01:16:06] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979a9a3d39a72.62917885.ogg","media_type":"audio","caption":null,"filename":"record_1769580961330.webm"} +[2026-01-28 01:16:07] Upload result: {"id":"1601261651067176"} +[2026-01-28 01:16:07] Media ID obtained: 1601261651067176 +[2026-01-28 01:16:08] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNEJDQ0YzQUZENTU4RjVERDI5AA=="}]} +[2026-01-28 01:16:08] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNEJDQ0YzQUZENTU4RjVERDI5AA=="}]} +[2026-01-28 01:16:08] Saving to DB - content: record_1769580961330.webm, media_url: 1601261651067176, local_file: uploads/media_6979a9a3d39a72.62917885.ogg, local_thumb: null +[2026-01-28 01:25:23] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979abd12b8131.97353205.ogg","media_type":"audio","caption":null,"filename":"record_1769581518627.webm"} +[2026-01-28 01:25:23] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979abd12b8131.97353205.ogg","media_type":"audio","caption":null,"filename":"record_1769581518627.webm"} +[2026-01-28 01:25:24] Upload result: {"id":"1043532494648003"} +[2026-01-28 01:25:24] Media ID obtained: 1043532494648003 +[2026-01-28 01:25:25] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMDE3NzA2RUU4QTcyMDYyQzZFAA=="}]} +[2026-01-28 01:25:25] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMDE3NzA2RUU4QTcyMDYyQzZFAA=="}]} +[2026-01-28 01:25:26] Saving to DB - content: record_1769581518627.webm, media_url: 1043532494648003, local_file: uploads/media_6979abd12b8131.97353205.ogg, local_thumb: null +[2026-01-28 01:49:36] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979b17f07a0f4.63241756.mp4","media_type":"video","caption":null,"filename":"WhatsApp Video 2026-01-22 at 10.53.30.mp4"} +[2026-01-28 01:49:36] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979b17f07a0f4.63241756.mp4","media_type":"video","caption":null,"filename":"WhatsApp Video 2026-01-22 at 10.53.30.mp4"} +[2026-01-28 01:49:38] Upload result: {"id":"2079449202816102"} +[2026-01-28 01:49:38] Media ID obtained: 2079449202816102 +[2026-01-28 01:49:39] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMjNGNDM0MzkxM0QxNURBODExAA=="}]} +[2026-01-28 01:49:39] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMjNGNDM0MzkxM0QxNURBODExAA=="}]} +[2026-01-28 01:49:39] Saving to DB - content: WhatsApp Video 2026-01-22 at 10.53.30.mp4, media_url: 2079449202816102, local_file: uploads/media_6979b17f07a0f4.63241756.mp4, local_thumb: uploads/media_6979b17f07a0f4.63241756.mp4 +[2026-01-28 01:51:40] Raw input: {"recipient":"573022548060","media_url":"http://localhost:8080/uploads/media_6979b1fb55d5a8.95537352.png","media_type":"image","caption":null,"filename":"image.png"} +[2026-01-28 01:51:40] Input decoded: {"recipient":"573022548060","media_url":"http:\/\/localhost:8080\/uploads\/media_6979b1fb55d5a8.95537352.png","media_type":"image","caption":null,"filename":"image.png"} +[2026-01-28 01:51:42] Upload result: {"id":"928500006280411"} +[2026-01-28 01:51:42] Media ID obtained: 928500006280411 +[2026-01-28 01:51:43] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMUM4NTYwOTc0QjBCQUJGQjBDAA=="}]} +[2026-01-28 01:51:43] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMUM4NTYwOTc0QjBCQUJGQjBDAA=="}]} +[2026-01-28 01:51:43] Saving to DB - content: image.png, media_url: 928500006280411, local_file: uploads/media_6979b1fb55d5a8.95537352.png, local_thumb: uploads/media_6979b1fb55d5a8.95537352.png diff --git a/api/upload_media.php b/api/upload_media.php index 856e44f..b1eedb2 100644 --- a/api/upload_media.php +++ b/api/upload_media.php @@ -63,9 +63,9 @@ try { $allowedTypes = [ // Imágenes 'image/jpeg', 'image/jpg', 'image/png', 'image/webp', - // Videos - 'video/mp4', 'video/3gpp', 'video/quicktime', - // Audios + // Videos (webm será convertido a mp4) + 'video/mp4', 'video/3gpp', 'video/quicktime', 'video/webm', + // Audios (webm será convertido a ogg) 'audio/aac', 'audio/mp3', 'audio/mpeg', 'audio/ogg', 'audio/amr', 'audio/webm', // Documentos 'application/pdf', @@ -97,38 +97,52 @@ try { throw new Exception('Error al guardar el archivo en el servidor'); } - // Si es audio WebM, intentar convertir a OGG/Opus (formatos más compatibles con WhatsApp) + // Convertir archivos WebM (audio y video) a formatos compatibles con WhatsApp $converted = false; $conversion_error = null; - if (strpos($fileType, 'audio/webm') === 0) { + + if (strpos($fileType, 'audio/webm') === 0 || strpos($fileType, 'video/webm') === 0) { // Evitar fatal si shell_exec está deshabilitado en el hosting if (function_exists('shell_exec')) { $ffmpeg = trim(@shell_exec('which ffmpeg 2>/dev/null')); if ($ffmpeg) { try { - $convertedName = uniqid('media_', true) . '.ogg'; - $convertedPath = $uploadDir . $convertedName; - // Convertir a Opus (bitrate moderado). Forzamos formato OGG, mono 48kHz y mapeamos la primera pista de audio. - // Esto ayuda a evitar contenedores/streams extra que pueden causar que el archivo suene como ruido. - $cmd = escapeshellcmd($ffmpeg) . ' -y -i ' . escapeshellarg($uploadPath) . ' -map 0:a:0 -c:a libopus -b:a 64k -vbr on -ar 48000 -ac 1 -f ogg ' . escapeshellarg($convertedPath) . ' 2>&1'; + if (strpos($fileType, 'audio/webm') === 0) { + // Audio WebM -> OGG/Opus + $convertedName = uniqid('media_', true) . '.ogg'; + $convertedPath = $uploadDir . $convertedName; + // Convertir a Opus (bitrate moderado). Forzamos formato OGG, mono 48kHz y mapeamos la primera pista de audio. + $cmd = escapeshellcmd($ffmpeg) . ' -y -i ' . escapeshellarg($uploadPath) . ' -map 0:a:0 -c:a libopus -b:a 64k -vbr on -ar 48000 -ac 1 -f ogg ' . escapeshellarg($convertedPath) . ' 2>&1'; + $newType = 'audio/ogg'; + $logType = 'Audio'; + } else { + // Video WebM -> MP4 + $convertedName = uniqid('media_', true) . '.mp4'; + $convertedPath = $uploadDir . $convertedName; + // Convertir a MP4 con H.264 (compatible con WhatsApp) + $cmd = escapeshellcmd($ffmpeg) . ' -y -i ' . escapeshellarg($uploadPath) . ' -c:v libx264 -preset fast -crf 23 -c:a aac -b:a 128k -movflags +faststart ' . escapeshellarg($convertedPath) . ' 2>&1'; + $newType = 'video/mp4'; + $logType = 'Video'; + } + $out = @shell_exec($cmd); - // Añadir comprobación diagnóstica con "ffmpeg -i" sobre el archivo convertido para registrar detalles del stream + // Añadir comprobación diagnóstica con "ffmpeg -i" sobre el archivo convertido $probe = @shell_exec(escapeshellcmd($ffmpeg) . ' -i ' . escapeshellarg($convertedPath) . ' 2>&1'); + if (file_exists($convertedPath) && filesize($convertedPath) > 0) { // Reemplazar archivo original por el convertido @unlink($uploadPath); $uploadPath = $convertedPath; $uniqueName = $convertedName; - $fileType = 'audio/ogg'; + $fileType = $newType; $converted = true; - error_log('upload_media.php - Audio convertido a OGG/Opus: ' . $convertedName); + error_log("upload_media.php - $logType convertido: $convertedName"); error_log('upload_media.php - ffmpeg output: ' . substr($out ?: '', 0, 2000)); - error_log('upload_media.php - ffmpeg probe: -' . substr($probe ?: '', 0, 2000)); + error_log('upload_media.php - ffmpeg probe: ' . substr($probe ?: '', 0, 2000)); } else { $conversion_error = 'Conversion failed or no output'; error_log('upload_media.php - Falló conversión con ffmpeg. Output: ' . substr($out ?: '', 0, 2000)); - error_log('upload_media.php - ffmpeg probe after failure:\n' . substr($probe ?: '', 0, 2000)); + error_log('upload_media.php - ffmpeg probe after failure: ' . substr($probe ?: '', 0, 2000)); } } catch (Exception $ex) { $conversion_error = 'Conversion exception: ' . $ex->getMessage(); @@ -136,11 +150,11 @@ try { } } else { $conversion_error = 'ffmpeg not found'; - error_log('upload_media.php - ffmpeg no encontrado, no se puede convertir audio/webm.'); + error_log('upload_media.php - ffmpeg no encontrado, no se puede convertir webm.'); } } else { $conversion_error = 'shell_exec disabled'; - error_log('upload_media.php - shell_exec disabled, no se puede convertir audio/webm.'); + error_log('upload_media.php - shell_exec disabled, no se puede convertir webm.'); } } diff --git a/api/version/media-url_debug.log b/api/version/media-url_debug.log index b3a36ce..138174b 100644 --- a/api/version/media-url_debug.log +++ b/api/version/media-url_debug.log @@ -103,3 +103,160 @@ [2026-01-27 23:46:42] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 [2026-01-27 23:46:42] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769575902&hash=ARlgJj9uEQBbCft9SWvCsd7Muroo_d46iIYJwmdSwrQWLw [2026-01-27 23:46:42] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769575902&hash=ARmC7xUghrqeNvaMeZgme9RMrbd771C1nty9RLOqJVItWA +[2026-01-28 00:02:21] Request: GET /api/version/media-url.php?id=3100504000137603&download=1 GET:{"id":"3100504000137603","download":"1"} POST:[] +[2026-01-28 00:02:21] Graph API request to https://graph.facebook.com/v22.0/3100504000137603 +[2026-01-28 00:12:36] Request: GET /api/version/media-url.php?id=876668735219378 GET:{"id":"876668735219378"} POST:[] +[2026-01-28 00:12:36] Graph API request to https://graph.facebook.com/v22.0/876668735219378 +[2026-01-28 00:12:36] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=876668735219378&source=getMedia&ext=1769577456&hash=ARmwFAN3qFOa9P44SrNAZBwNzLXLvix1Q6GCMlOZFsqrzA +[2026-01-28 00:21:12] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:21:12] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:21:12] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:21:12] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769577972&hash=ARmoanU8Nd36LwQ6xNz7eG63SBVvGepjczzi4M--a98BDg +[2026-01-28 00:21:12] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769577972&hash=ARl9BUAyWrmYag5aPXEyUWVVcM1w-zbjTOpuX5j7YfzG4A +[2026-01-28 00:31:03] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:31:03] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:31:03] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:31:03] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578563&hash=ARlRqx01CwGl-djJAkY2I4g-P5m7smHw95Wlm1kBJSiSDA +[2026-01-28 00:31:03] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769578563&hash=ARmRofVHmPDUfJd1iAsyrPYbxenS2CgxlZKyZHE9Q76DqQ +[2026-01-28 00:31:18] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:31:18] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:31:18] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:31:18] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578578&hash=ARnVWo2U8tL_Yq7kNT0S7iXoCbZSIz9bLJkah-zCi3_8UA +[2026-01-28 00:31:18] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769578578&hash=ARkDgAhqSzlVEdZj9OnaTFiddRAO4GN39Xpsd2XdUL3Ycw +[2026-01-28 00:31:52] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:31:52] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578612&hash=ARkn0okswwjwqUMNGWslpAzw_X5imoSyIt14oVH7j56AOw +[2026-01-28 00:32:15] Request: GET /api/version/media-url.php?id=1983961412192518 GET:{"id":"1983961412192518"} POST:[] +[2026-01-28 00:32:15] Graph API request to https://graph.facebook.com/v22.0/1983961412192518 +[2026-01-28 00:32:15] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1983961412192518&source=getMedia&ext=1769578635&hash=ARl8bnodHLay57oSohSgIppcpZ1x0NRoRzoeCufGANhUuA +[2026-01-28 00:35:55] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:35:55] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:35:55] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:35:56] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578856&hash=ARl46VfeoC_hpowfcJ8uwH4Bu6RKKGeMG-SdRCmDyEpAlg +[2026-01-28 00:35:56] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769578856&hash=ARkbJHqldIyUkRCtH85bL0HgIoErQ8zBKtzpeuLl_Olxuw +[2026-01-28 00:36:12] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:36:13] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578873&hash=ARmQJn2gapAIIEOwHDt6s7kI1g0IHYc0x2ChKjKSU_R7FA +[2026-01-28 00:36:32] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:36:33] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769578893&hash=ARmoYK93esbPfBmwtIcgZ_3J-9DQfmwnT_5A-SXbay5crw +[2026-01-28 00:36:59] Request: GET /api/version/media-url.php?id=3480062748838248 GET:{"id":"3480062748838248"} POST:[] +[2026-01-28 00:36:59] Graph API request to https://graph.facebook.com/v22.0/3480062748838248 +[2026-01-28 00:36:59] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3480062748838248&source=getMedia&ext=1769578919&hash=ARnnGogjEuOzgaECbYMz20tpgiudo_nyTmLtnXOI4vPgqw +[2026-01-28 00:39:29] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:39:29] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:39:30] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769579070&hash=ARkKPaxFRIZGRlwW9mNRyF3oUAtq4Q-zr989V8MwIBzyLw +[2026-01-28 00:39:30] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:39:30] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579070&hash=ARmTcu9TN2oxQK2RIP960qWtzYwsbK9HNN56QveOc6GpIw +[2026-01-28 00:42:27] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:42:27] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:42:27] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769579247&hash=ARkY9LAAA7csYlYr-SW3f3GlOKJnR9KGm_Ck3Q3YzUl07Q +[2026-01-28 00:42:28] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:42:28] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579248&hash=ARkP81S6ZYYxl_m5jEnb5ILAMfdGBHKRFQBckN9exlZYZA +[2026-01-28 00:46:44] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:46:44] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:46:44] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:46:44] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579504&hash=ARmTFmCOFSKbhtRfAK92DvtWo4GPZjeaeiJUsFy5hDbtEQ +[2026-01-28 00:46:45] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769579505&hash=ARk0PxLzqiGSL5obxGtS5BU09ARd5uqK6XJKL1_Sw5WSRg +[2026-01-28 00:47:08] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:47:08] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579528&hash=ARmRbSE47_fis_BjpvpeQbA-00ywmKSUuZQjIAWvoAIlcQ +[2026-01-28 00:49:35] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:49:35] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:49:35] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:49:35] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579675&hash=ARkIayYGe-1jZ0mTJeA7M893JUhie6RGrFzeDetowshI5w +[2026-01-28 00:49:35] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769579675&hash=ARnUJ8I9qM_rzdz7BWv-22oSEXi7SFVI5QGFjUwCHz_3kA +[2026-01-28 00:50:34] Request: GET /api/version/media-url.php?id=1551128883003002&download=1 GET:{"id":"1551128883003002","download":"1"} POST:[] +[2026-01-28 00:50:34] Graph API request to https://graph.facebook.com/v22.0/1551128883003002 +[2026-01-28 00:51:09] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:51:09] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579769&hash=ARl25XtRezFQE4LNk2ltWGpUCH8fGtGyGhMjVSRFLbeVLg +[2026-01-28 00:53:47] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:53:47] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:53:47] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:53:47] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579927&hash=ARnKJqihLQvUOsIMvDxRl6_ToIWFolgiMwv0EpQtAce_WQ +[2026-01-28 00:53:47] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769579927&hash=ARmluaFcjYAHj3AUqm9kT96xYB2wn-NMyVSa36eFyj6jkQ +[2026-01-28 00:54:22] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:54:22] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769579962&hash=ARmKutEdaebPLIDdbo5NFxqUgqL_itap2Rs-929uRkbm1w +[2026-01-28 00:54:55] Request: GET /api/version/media-url.php?local=uploads%2Fmedia_6979a2d407f105.12184484.jpg GET:{"local":"uploads\/media_6979a2d407f105.12184484.jpg"} POST:[] +[2026-01-28 00:55:25] Request: GET /api/version/media-url.php?local=uploads%2Fmedia_6979a2d407f105.12184484.jpg GET:{"local":"uploads\/media_6979a2d407f105.12184484.jpg"} POST:[] +[2026-01-28 00:55:33] Request: GET /api/version/media-url.php?local=uploads%2Fmedia_6979a2d407f105.12184484.jpg GET:{"local":"uploads\/media_6979a2d407f105.12184484.jpg"} POST:[] +[2026-01-28 00:58:18] Request: GET /api/version/media-url.php?local=uploads%2Fmedia_6979a2d407f105.12184484.jpg GET:{"local":"uploads\/media_6979a2d407f105.12184484.jpg"} POST:[] +[2026-01-28 00:59:02] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:59:02] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 00:59:02] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 00:59:02] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769580242&hash=ARlmivoTwZhpdMULc1VdeSk_2GQXSHx9_SXYGbF7AJ9Fag +[2026-01-28 00:59:02] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769580242&hash=ARmenndhGQKTEctc9p9lc9F4cGFTr6IMx88N3iL_RuT3Zw +[2026-01-28 00:59:24] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 00:59:25] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769580265&hash=ARnOU-1V45VtKJI2XzRFHD6BSyGBjUSTIqGJdBzs933bAw +[2026-01-28 01:03:12] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:03:12] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:03:12] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:03:12] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769580492&hash=ARn93MHvoEKXeawiU3sBI9u3xVB0plX3bNOc6FHj9WVFog +[2026-01-28 01:03:12] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769580492&hash=ARnWkfo-X22eZ-dKOhkni6yzUXhTOsS38uIW7LG8F_Grng +[2026-01-28 01:08:42] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:08:42] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:08:42] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:08:42] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769580822&hash=ARmzjPWWs1VtMhON00noHMjb2S7Z2NzzMXQS6kRVWz_GMw +[2026-01-28 01:08:42] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769580822&hash=ARmsky0v0oPn3oem400y-tAQQ6n44y-Pr5A0Fy4_ym08Sw +[2026-01-28 01:10:45] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:10:45] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:10:45] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:10:45] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769580945&hash=ARk25aum1ipZPmiCLuvdicHJb9ex0rx8OaT5Z0NPRd3GZw +[2026-01-28 01:10:45] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769580945&hash=ARmIfLoMEJXUbvwj3h6IgyLZDGarDY5dvQtTZtWbpqJYxA +[2026-01-28 01:15:57] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:15:57] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:15:57] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:15:57] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581257&hash=ARnrEU19RUEQsZDRQEZQS0vD9QujFwJ4sA02YqQJ-37OVg +[2026-01-28 01:15:57] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769581257&hash=ARnlPUXu741I3wXzXm6Ns1UjsSVnJuh5AJaHUnDk7TuUug +[2026-01-28 01:16:11] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:16:12] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581272&hash=ARkFqWHyaasxAljVpFWiD6HLQKSQ4D_yd8JsDrVUREalQQ +[2026-01-28 01:18:55] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:18:55] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:18:55] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:18:55] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769581435&hash=ARnFdlxA1CZ7s6df99Lvrksxj0tPcjzREd7IzTEHuGfF2A +[2026-01-28 01:18:55] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581435&hash=ARlLQ93XXsVGb4xTDoy6pa5bceRwLUBQ2Tb58-5qx8tcRA +[2026-01-28 01:19:33] Request: GET /api/version/media-url.php?id=1601261651067176&download=1 GET:{"id":"1601261651067176","download":"1"} POST:[] +[2026-01-28 01:19:33] Graph API request to https://graph.facebook.com/v22.0/1601261651067176 +[2026-01-28 01:19:42] Request: GET /api/version/media-url.php?local=uploads%2Fmedia_6979a2d407f105.12184484.jpg GET:{"local":"uploads\/media_6979a2d407f105.12184484.jpg"} POST:[] +[2026-01-28 01:20:39] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:20:39] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:20:39] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769581539&hash=ARn5A34U8V_qmSuZQJl7xYix7Lr-CC8DI-K36SgrcqJyRA +[2026-01-28 01:22:26] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:22:26] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:22:26] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:22:26] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581646&hash=ARnEOR2YXK9c-xUeehKuZrowGgZ5KIuC8VZjf2Xr0IIpAQ +[2026-01-28 01:22:26] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769581646&hash=ARlhztt7jCFwChEJOM-PvQ47LBfjik-w6ljnvfuI9i8efw +[2026-01-28 01:24:47] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:24:47] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:24:47] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769581787&hash=ARnzH0guEPfWRWU51ldsgxmZs966Qd8Qfle7rEW1nLggaQ +[2026-01-28 01:24:47] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:24:47] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581787&hash=ARnFw0RXJtxRRVYmhMD3oeFTJiGiMxb-G4tV3pBjNL6_SQ +[2026-01-28 01:25:29] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:25:29] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769581829&hash=ARlRzKB6IF46_AlDA7o7gapnrQFJPQ8sDJgCHWB8iHILJQ +[2026-01-28 01:30:00] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:30:00] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:30:00] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:30:00] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769582100&hash=ARkKkePqgcaQambyFaT-q7fmcItK9CRzre9LqZ99MY2tRQ +[2026-01-28 01:30:00] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769582100&hash=ARkk8hsjClEX4fhebbWogS6yUSnR0tf6xibLB3OFl_m8yw +[2026-01-28 01:49:29] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:49:29] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:49:29] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:49:29] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583269&hash=ARlsuHrQo0NV1y3mLfDFwu6VKo6zw0Vft-xdrNbqwNDKSw +[2026-01-28 01:49:30] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769583269&hash=ARl8a7X-B2EJZVDbLlIu-9SHY0U7d-qv_iJm7eG75GiYCA +[2026-01-28 01:49:42] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:49:43] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583283&hash=ARkFBlfW7vGkyhucCoWVgirgWMi4rSfVsXmiPIqExxtM8A +[2026-01-28 01:51:22] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 01:51:22] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:51:22] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 01:51:22] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769583382&hash=ARlNJc4-zhtmMDC6ZX5YvLG-QZlcNIjMX7IpNB6Z6YzdOA +[2026-01-28 01:51:22] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583382&hash=ARlZV7UnYDg_jagmLF6YEbGh8v50rUfxYFEw-yLNBBgbHg +[2026-01-28 01:51:46] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:51:47] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583407&hash=ARnwqEl9qw2RK6Yd9gAXYj8TNbqqqMGIspUjWdE6nqhL1Q +[2026-01-28 01:52:04] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 01:52:04] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583424&hash=ARl_asnI_rejXyYQaCO7NAYFbfQpBDdRxmWzt-CmmJUrCg +[2026-01-28 02:00:11] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 02:00:11] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 02:00:11] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 02:00:11] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769583911&hash=ARkOiy7N3swvb64kubAAcPhyEaoXC5Pf96qQK8dlGjfZRw +[2026-01-28 02:00:11] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583911&hash=ARnR5vosdyiSyrizuAG-OROPmxikGRc-vT-PPe2VbT13Xg +[2026-01-28 02:00:25] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-01-28 02:00:25] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-01-28 02:00:25] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-01-28 02:00:26] Resolved media URL from Graph for mid 2371342336638440: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=getMedia&ext=1769583926&hash=ARkwnC8kELAgDSp4Qy8qvU3cY6trphM71K08Ebb3rQDeXg +[2026-01-28 02:00:26] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1217156256734654&source=getMedia&ext=1769583926&hash=ARk42Fz7IB5FhjLHoVW-GF05cM0WjbFZU0NerKLOUo1W9g diff --git a/assets/js/chat-common.js b/assets/js/chat-common.js index 804adb8..c0910f0 100644 --- a/assets/js/chat-common.js +++ b/assets/js/chat-common.js @@ -37,6 +37,8 @@ function isValidMediaUrl(u) { function ensureProxyUrl(u, download = false) { if (!isValidMediaUrl(u)) return ''; if (u.startsWith('/') || u.indexOf('/api/version/media-url.php') === 0) return u; + // Si empieza con api/ agregar / al inicio + if (u.startsWith('api/')) return '/' + u; try { const parsed = new URL(u); const host = parsed.host.toLowerCase(); @@ -84,7 +86,8 @@ function renderMediaMessage(msg) { // Full URL for opening (prefer local file then external with id or url) let fullUrl = ''; if (isValidMediaUrl(localFile)) { - fullUrl = `/api/version/media-url.php?local=${encodeURIComponent(localFile)}`; + // Usar archivo local directamente sin proxy + fullUrl = localFile.startsWith('/') ? localFile : `/${localFile}`; } else if (isValidMediaUrl(mediaExternal)) { let mid = ''; if (mediaExternal.indexOf('api/get_media.php?id=') !== -1) { @@ -108,16 +111,28 @@ function renderMediaMessage(msg) { return `
Imagen no disponible
`; } case 'video': { - const src = ensureProxyUrl(effective || msg.media_url || ''); + // Priorizar local_file sobre otras fuentes + let src = ''; + if (isValidMediaUrl(localFile)) { + src = localFile.startsWith('/') ? localFile : `/${localFile}`; + } else { + src = ensureProxyUrl(effective || msg.media_url || ''); + } if (src) return `
${content?`
${escapeHtml(content)}
`:''}`; return `
Video no disponible
`; } case 'audio': { - const src = ensureProxyUrl(effective || msg.media_url || ''); + // Priorizar local_file sobre otras fuentes + let src = ''; + if (isValidMediaUrl(localFile)) { + src = localFile.startsWith('/') ? localFile : `/${localFile}`; + } else { + src = ensureProxyUrl(effective || msg.media_url || ''); + } if (!src) return `
Audio no disponible
`; // build download link when possible (api/get_media.php?id=... or direct url or local file) let audioDownload = null; - const candidate = isValidMediaUrl(effective) ? effective : (isValidMediaUrl(msg.media_url) ? msg.media_url : (isValidMediaUrl(localFile) ? localFile : null)); + const candidate = isValidMediaUrl(localFile) ? localFile : (isValidMediaUrl(effective) ? effective : (isValidMediaUrl(msg.media_url) ? msg.media_url : null)); if (candidate && candidate.indexOf && candidate.indexOf('api/get_media.php?id=') !== -1) { const parts = candidate.split('id='); const mid = parts[1] ? parts[1] : ''; @@ -125,7 +140,8 @@ function renderMediaMessage(msg) { } else if (candidate && /^https?:\/\//i.test(candidate)) { audioDownload = `/api/version/media-url.php?url=${encodeURIComponent(candidate)}&download=1`; } else if (candidate && candidate === localFile) { - audioDownload = `/api/version/media-url.php?local=${encodeURIComponent(candidate)}&download=1`; + // Usar archivo local directamente sin proxy + audioDownload = localFile.startsWith('/') ? localFile : `/${localFile}`; } let html = `
`; @@ -143,7 +159,8 @@ function renderMediaMessage(msg) { } else if (isValidMediaUrl(mediaExternal) && /^https?:\/\//i.test(mediaExternal)) { docUrl = `/api/version/media-url.php?url=${encodeURIComponent(mediaExternal)}&download=1`; } else if (isValidMediaUrl(localFile)) { - docUrl = `/api/version/media-url.php?local=${encodeURIComponent(localFile)}&download=1`; + // Usar archivo local directamente sin proxy + docUrl = localFile.startsWith('/') ? localFile : `/${localFile}`; } if (docUrl) return `${escapeHtml(filename)}`; return `
${escapeHtml(filename)} (No disponible)
`; diff --git a/config/config.php b/config/config.php index 708c319..a345d7c 100644 --- a/config/config.php +++ b/config/config.php @@ -5,12 +5,12 @@ * Fecha: 4 de enero de 2026 - Sistema de autenticación unificado */ -// Configuración de la base de datos (compatible con cPanel) -define('DB_HOST', '77.37.126.126'); -define('DB_PORT', '3306'); -define('DB_NAME', 'usite_whatsapp_bot'); -define('DB_USER', 'usite_whatsapp_user'); -define('DB_PASS', '6q!Vio0fn@PFmsLyHjH5'); // Se generará automáticamente en la instalación +// Configuración de la base de datos - usa variables de entorno si están disponibles +define('DB_HOST', getenv('DB_HOST') ?: '77.37.126.126'); +define('DB_PORT', getenv('DB_PORT') ?: '3306'); +define('DB_NAME', getenv('DB_NAME') ?: 'usite_whatsapp_bot'); +define('DB_USER', getenv('DB_USER') ?: 'usite_whatsapp_user'); +define('DB_PASS', getenv('DB_PASS') ?: '6q!Vio0fn@PFmsLyHjH5'); define('DB_CHARSET', 'utf8mb4'); // Configuración de autenticación (LEGACY - migrado a BD) diff --git a/conversations.php b/conversations.php index efbab35..b11bde1 100644 --- a/conversations.php +++ b/conversations.php @@ -1425,6 +1425,9 @@ if (!isset($_SESSION['user_id'])) { // Solo incrementar unread_count si no es la conversación activa if (String(this.currentUserId) !== String(userId)) { conv.unread_count = (conv.unread_count || 0) + 1; + } else { + // Si es la conversación activa, mantener unread_count en 0 + conv.unread_count = 0; } // Mover al inicio de la lista @@ -1445,8 +1448,7 @@ if (!isset($_SESSION['user_id'])) { // Re-renderizar solo la lista de conversaciones console.log('🔄 Re-renderizando lista de conversaciones...'); - console.log('🔍 Verificando this:', this); - console.log('🔍 this.renderConversations existe?', typeof this.renderConversations); + console.log('🔍 Filtro activo:', this.conversationFilter); console.log('🔍 this.conversations:', this.conversations); if (typeof this.renderConversations === 'function') { @@ -2252,8 +2254,14 @@ if (!isset($_SESSION['user_id'])) { filterSelect.value = this.conversationFilter; filterSelect.addEventListener('change', (e) => { this.conversationFilter = e.target.value || 'all'; - // reload conversations from first page - this.loadConversations(1, false); + console.log('🔍 Filtro cambiado a:', this.conversationFilter); + // Re-renderizar la lista actual sin recargar desde el servidor + this.renderConversations(); + // También recargar desde el servidor para asegurar datos actualizados + // (pero esto es secundario y puede ser en background) + this.loadConversations(1, false).catch(err => { + console.warn('Error recargando conversaciones después de cambiar filtro:', err); + }); }); } } @@ -2505,8 +2513,16 @@ if (!isset($_SESSION['user_id'])) { } console.log('✅ Container encontrado:', container); + console.log('🔍 Filtro activo:', this.conversationFilter); - if (this.conversations.length === 0) { + // Aplicar filtro de no leídos + let conversationsToShow = this.conversations; + if (this.conversationFilter === 'unread') { + conversationsToShow = this.conversations.filter(c => (c.unread_count || 0) > 0); + console.log(`🔍 Filtro 'unread' aplicado: ${conversationsToShow.length} de ${this.conversations.length} conversaciones`); + } + + if (conversationsToShow.length === 0) { const emptyMsg = this.conversationFilter === 'unread' ? 'No hay conversaciones no leídas' : 'No hay conversaciones aún'; container.innerHTML = `
@@ -2518,13 +2534,35 @@ if (!isset($_SESSION['user_id'])) { return; } - console.log('📋 Generando HTML para', this.conversations.length, 'conversaciones'); + console.log('📋 Generando HTML para', conversationsToShow.length, 'conversaciones'); // Ahora el backend devuelve por usuario: last_message, last_time, unread_count y avatar_url - const html = this.conversations.map(conv => { + const html = conversationsToShow.map(conv => { const isActive = conv.user_id == this.currentUserId ? 'active' : ''; const time = this.formatTime(conv.last_time); - const preview = this.truncateText(conv.last_message || 'Sin mensajes', 50); + + // Mostrar miniatura si el último mensaje es multimedia y tiene archivo local + let preview = ''; + const hasLocalMedia = conv.last_local_file || conv.last_local_thumb; + const isMediaType = conv.message_type && ['image', 'video', 'audio', 'document'].includes(conv.message_type); + + if (hasLocalMedia && isMediaType) { + const thumbSrc = conv.last_local_thumb || conv.last_local_file; + const mediaIcon = { + 'image': '🖼️', + 'video': '🎥', + 'audio': '🎵', + 'document': '📎' + }[conv.message_type] || '📎'; + + if (conv.message_type === 'image' || conv.message_type === 'video') { + preview = `media ${mediaIcon} ${conv.last_message || 'Multimedia'}`; + } else { + preview = `${mediaIcon} ${conv.last_message || 'Archivo'}`; + } + } else { + preview = this.truncateText(conv.last_message || 'Sin mensajes', 50); + } const avatar = conv.avatar_url ? `avatar` : `
${this.getInitials(conv.name)}
`; @@ -2555,7 +2593,7 @@ if (!isset($_SESSION['user_id'])) { console.log('📄 HTML generado, longitud:', html.length, 'caracteres'); - // Detectar nuevas notificaciones: comparar unread counts previos + // Detectar nuevas notificaciones: comparar unread counts previos (usar todas las conversaciones, no solo las filtradas) if (!this._prevConversations) this._prevConversations = {}; this.conversations.forEach(c => { const prev = this._prevConversations[c.user_id] || { unread_count: 0 }; @@ -2690,6 +2728,14 @@ if (!isset($_SESSION['user_id'])) { // Clear any staged messages from a previous conversation and hide indicator try { if (this._stagedMessageIds) { this._stagedMessageIds.clear(); this._stagedCount = 0; this.hideNewMessagesIndicator(); } } catch(e) {} + // Actualizar inmediatamente el contador de no leídos a 0 en la lista local + const conv = this.conversations.find(c => c.user_id === userId); + if (conv) { + conv.unread_count = 0; + // Re-renderizar la lista para reflejar el cambio inmediatamente + this.renderConversations(); + } + // Actualizar UI document.getElementById('no-conversation').style.display = 'none'; document.getElementById('chat-area').style.display = 'flex'; @@ -2706,8 +2752,7 @@ if (!isset($_SESSION['user_id'])) { }); document.querySelector(`[data-user-id="${userId}"]`)?.classList.add('active'); - // Actualizar estado del toggle del bot según datos de la conversación - const conv = this.conversations.find(c => c.user_id === userId); + // Actualizar estado del toggle del bot según datos de la conversación (ya obtuvimos conv arriba) if (conv) { const btn = document.getElementById('bot-toggle'); const holdIndicator = document.getElementById('hold-indicator'); @@ -4744,6 +4789,7 @@ if (!isset($_SESSION['user_id'])) { const uploadResponse = await fetch('api/upload_media.php', { method: 'POST', + credentials: 'same-origin', // Enviar cookies de sesión body: formData }); const uploadContentType = uploadResponse.headers.get('content-type') || ''; @@ -4769,6 +4815,7 @@ if (!isset($_SESSION['user_id'])) { const sendResponse = await fetch('api/send_media_message.php', { method: 'POST', + credentials: 'same-origin', // Enviar cookies de sesión headers: { 'Content-Type': 'application/json' }, @@ -4834,9 +4881,13 @@ if (!isset($_SESSION['user_id'])) { } // Éxito + console.log('✅ Archivo enviado exitosamente, recargando mensajes...'); this.cancelMediaUpload(); - await this.loadconversations(this.currentUserId, false); - // SSE actualizará las conversaciones automáticamente + + // Recargar mensajes para mostrar el multimedia recién enviado + await this.loadMessages(this.currentUserId, true, true); + + // SSE actualizará las conversaciones en la lista automáticamente // this.loadConversations(); } catch (error) { @@ -4867,27 +4918,60 @@ if (!isset($_SESSION['user_id'])) { renderMediaMessage(message) { if (!message) return ''; const mediaType = message.message_type || message.media_type || 'text'; - const mediaUrl = message.media_url || message.media_url_external || ''; + const mediaUrl = message.media_url || ''; + const mediaUrlExternal = message.media_url_external || ''; const caption = message.content || ''; const localFile = message.local_file || ''; const localThumb = message.local_thumb || ''; - const thumb = localThumb ? (`/${localThumb}`) : (localFile ? (`/${localFile}`) : (message.media_url_external || mediaUrl)); - + const messageId = message.id || message.message_id || ''; + + // Debug completo del mensaje + if (mediaType === 'audio' || mediaType === 'image' || mediaType === 'video') { + console.log(`🎵 Media message (${mediaType}) - Datos completos:`, { + id: messageId, + localFile: localFile, + localThumb: localThumb, + mediaUrl: mediaUrl, + mediaUrlExternal: mediaUrlExternal, + hasLocalFile: !!localFile, + messageType: mediaType + }); + } + + // Prioridad: archivo local > proxy con DB id > media_url_external > URL externa let full = ''; + let thumb = ''; + if (localFile) { - full = `/api/version/media-url.php?local=${encodeURIComponent(localFile)}`; - } else if (message.media_url_external) { - if (message.media_url_external.indexOf('api/get_media.php?id=') !== -1) { - const parts = message.media_url_external.split('id='); - const mid = parts[1] ? decodeURIComponent(parts[1]) : ''; - full = `/api/version/media-url.php?id=${encodeURIComponent(mid)}`; - } else if (/^https?:\/\//i.test(message.media_url_external)) { - full = message.media_url_external; - } else { - full = `/api/version/media-url.php?url=${encodeURIComponent(message.media_url_external)}`; - } + // ✅ PRIORIDAD 1: Archivo local guardado + full = `/${localFile}`; + thumb = localThumb ? `/${localThumb}` : `/${localFile}`; + console.log('✅ Usando archivo local:', full); + } else if (messageId && !mediaUrlExternal) { + // ⚠️ PRIORIDAD 2: Usar proxy con el ID de la base de datos solo si no hay media_url_external + full = `/api/version/media-url.php?id=${encodeURIComponent(messageId)}`; + thumb = full; + console.log('⚠️ No hay local_file, usando proxy con messageId:', messageId); + } else if (mediaUrlExternal) { + // 🔄 PRIORIDAD 3: Usar media_url_external (puede ser api/get_media.php o URL directa) + full = mediaUrlExternal.startsWith('/') ? mediaUrlExternal : `/${mediaUrlExternal}`; + thumb = full; + console.log('🔄 Usando media_url_external:', full); + } else if (mediaUrl && /^\d+$/.test(mediaUrl)) { + // 📱 PRIORIDAD 4: Es un ID de WhatsApp (solo números) + full = `/api/get_media.php?id=${encodeURIComponent(mediaUrl)}`; + thumb = full; + console.log('📱 Usando whatsapp_media_id con get_media.php:', mediaUrl); + } else if (mediaUrl && /^https?:\/\//i.test(mediaUrl)) { + // 🌐 PRIORIDAD 5: URL externa directa (puede estar caducada) + full = mediaUrl; + thumb = mediaUrl; + console.log('🌐 Usando URL externa:', full); } else { - full = mediaUrl || ''; + // ❌ Fallback: sin media disponible + console.warn('❌ No hay fuente de media disponible para el mensaje', messageId); + full = ''; + thumb = ''; } switch (mediaType) { @@ -4913,22 +4997,8 @@ if (!isset($_SESSION['user_id'])) { ${caption ? `
${escapeHtml(caption)}
` : ''} `; case 'audio': { - let audioSrc = ''; - if (localFile) { - audioSrc = `/${localFile}`; - } else if (message.media_url_external) { - if (message.media_url_external.indexOf('api/get_media.php?id=') !== -1) { - const parts = message.media_url_external.split('id='); - const mid = parts[1] ? decodeURIComponent(parts[1]) : ''; - audioSrc = `/api/version/media-url.php?id=${encodeURIComponent(mid)}`; - } else if (/^https?:\/\//i.test(message.media_url_external)) { - audioSrc = message.media_url_external; - } else { - audioSrc = `/api/version/media-url.php?url=${encodeURIComponent(message.media_url_external)}`; - } - } else { - audioSrc = mediaUrl; - } + // Para audio, usar la misma lógica de full + let audioSrc = full; return `