funcional

This commit is contained in:
lizandrogd
2026-01-12 14:08:21 -05:00
parent e1b0ded7d9
commit 4b7bcb6924
5 changed files with 47 additions and 31 deletions
+8 -6
View File
@@ -31,9 +31,9 @@ try {
// 1. Verificar configuración básica // 1. Verificar configuración básica
$diagnostic['config_status'] = [ $diagnostic['config_status'] = [
'phone_number_id' => !empty($whatsappConfig['phone_number_id']), 'phone_number_id' => !empty($whatsappConfig['phone_number_id']),
'access_token' => !empty($whatsappConfig['access_token']),
'webhook_verify_token' => !empty($whatsappConfig['webhook_verify_token']), 'webhook_verify_token' => !empty($whatsappConfig['webhook_verify_token']),
'business_account_id' => !empty($whatsappConfig['business_account_id']) 'whatsapp_api_url' => !empty($whatsappConfig['whatsapp_api_url']),
'whatsapp_token' => !empty($whatsappConfig['whatsapp_token'])
]; ];
$diagnostic['config_status']['complete'] = array_reduce($diagnostic['config_status'], function($carry, $item) { $diagnostic['config_status']['complete'] = array_reduce($diagnostic['config_status'], function($carry, $item) {
@@ -60,9 +60,9 @@ try {
// 3. Test básico de API (solo si hay configuración completa) // 3. Test básico de API (solo si hay configuración completa)
if ($diagnostic['config_status']['complete']) { if ($diagnostic['config_status']['complete']) {
$apiUrl = "https://graph.facebook.com/v18.0/{$whatsappConfig['phone_number_id']}"; $apiUrl = "https://graph.facebook.com/v22.0/{$whatsappConfig['phone_number_id']}";
$headers = [ $headers = [
'Authorization: Bearer ' . $whatsappConfig['access_token'], 'Authorization: Bearer ' . $whatsappConfig['whatsapp_token'],
'Content-Type: application/json' 'Content-Type: application/json'
]; ];
@@ -88,7 +88,9 @@ try {
} else { } else {
$diagnostic['api_status'] = [ $diagnostic['api_status'] = [
'reachable' => false, 'reachable' => false,
'error' => 'No se pudo conectar con la API de WhatsApp' #'error' => 'No se pudo conectar con la API de WhatsApp',
'error' => error_get_last()
]; ];
} }
} else { } else {
@@ -122,7 +124,7 @@ try {
// Agregar compatibilidad con la estructura esperada en index.php // Agregar compatibilidad con la estructura esperada en index.php
$configComplete = $diagnostic['config_status']['complete']; $configComplete = $diagnostic['config_status']['complete'];
$completionPercentage = 0; $completionPercentage = 0;
$configFields = ['phone_number_id', 'access_token', 'webhook_verify_token', 'business_account_id']; $configFields = ['phone_number_id', 'whatsapp_token', 'webhook_verify_token', 'whatsapp_api_url'];
$completedFields = 0; $completedFields = 0;
foreach ($configFields as $field) { foreach ($configFields as $field) {
+3 -1
View File
@@ -489,9 +489,10 @@ class SimpleWhatsAppManager {
if (!data) return; if (!data) return;
const fields = [ const fields = [
{ id: 'whatsapp-token', value: data.token }, { id: 'whatsapp-token', value: data.whatsapp_token },
{ id: 'phone-number-id', value: data.phone_number_id }, { id: 'phone-number-id', value: data.phone_number_id },
{ id: 'webhook-token', value: data.webhook_verify_token }, { id: 'webhook-token', value: data.webhook_verify_token },
{ id: 'api-url', value: data.api_url },
{ id: 'business-name', value: data.business_name }, { id: 'business-name', value: data.business_name },
{ id: 'welcome-message', value: data.welcome_message } { id: 'welcome-message', value: data.welcome_message }
]; ];
@@ -514,6 +515,7 @@ class SimpleWhatsAppManager {
token: document.getElementById('whatsapp-token').value, token: document.getElementById('whatsapp-token').value,
phone_number_id: document.getElementById('phone-number-id').value, phone_number_id: document.getElementById('phone-number-id').value,
webhook_verify_token: document.getElementById('webhook-token').value, webhook_verify_token: document.getElementById('webhook-token').value,
api_url: document.getElementById('api-url').value,
business_name: document.getElementById('business-name').value, business_name: document.getElementById('business-name').value,
welcome_message: document.getElementById('welcome-message').value welcome_message: document.getElementById('welcome-message').value
}; };
+2 -2
View File
@@ -637,9 +637,9 @@ function saveWhatsAppConfigToDB($whatsappConfig) {
*/ */
function getWhatsAppConfigFromDB() { function getWhatsAppConfigFromDB() {
return [ return [
'token' => getConfigFromDB('whatsapp_token', ''), 'whatsapp_token' => getConfigFromDB('whatsapp_token', ''),
'phone_number_id' => getConfigFromDB('whatsapp_phone_number_id', ''), 'phone_number_id' => getConfigFromDB('whatsapp_phone_number_id', ''),
'api_url' => getConfigFromDB('whatsapp_api_url', 'https://graph.facebook.com/v22.0/'), 'whatsapp_api_url' => getConfigFromDB('whatsapp_api_url', 'https://graph.facebook.com/v22.0/'),
'webhook_verify_token' => getConfigFromDB('webhook_verify_token', ''), 'webhook_verify_token' => getConfigFromDB('webhook_verify_token', ''),
'business_name' => getConfigFromDB('business_name', ''), 'business_name' => getConfigFromDB('business_name', ''),
'welcome_message' => getConfigFromDB('welcome_message', ''), 'welcome_message' => getConfigFromDB('welcome_message', ''),
+8
View File
@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Página principal del sistema WhatsApp Bot * Página principal del sistema WhatsApp Bot
* Fecha: 13 de noviembre de 2025 * Fecha: 13 de noviembre de 2025
@@ -29,6 +30,7 @@ try {
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="es"> <html lang="es">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -38,6 +40,7 @@ try {
<link href="./assets/css/styles.css" rel="stylesheet"> <link href="./assets/css/styles.css" rel="stylesheet">
<link href="./assets/css/diagnostic.css" rel="stylesheet"> <link href="./assets/css/diagnostic.css" rel="stylesheet">
</head> </head>
<body> <body>
<!-- Sidebar --> <!-- Sidebar -->
<nav class="sidebar"> <nav class="sidebar">
@@ -470,6 +473,10 @@ try {
<label class="form-label">Webhook Verify Token</label> <label class="form-label">Webhook Verify Token</label>
<input type="text" class="form-control" id="webhook-token" placeholder="Token de verificación del webhook"> <input type="text" class="form-control" id="webhook-token" placeholder="Token de verificación del webhook">
</div> </div>
<div class="mb-3">
<label class="form-label">API URL</label>
<input type="text" class="form-control" id="api-url" placeholder="URL de la API" value="https://graph.facebook.com/v22.0/">
</div>
</div> </div>
<div class="mb-4"> <div class="mb-4">
@@ -738,4 +745,5 @@ try {
} }
</script> </script>
</body> </body>
</html> </html>
+4
View File
@@ -0,0 +1,4 @@
[2026-01-12 13:25:44] [INFO] Configuración de WhatsApp actualizada {"configured_fields":{"token":true,"phone_id":true,"webhook_token":true},"user":"debug_user"}
[2026-01-12 13:26:51] [INFO] Configuración de WhatsApp actualizada {"configured_fields":{"token":true,"phone_id":true,"webhook_token":true},"user":"debug_user"}
[2026-01-12 13:28:56] [INFO] Configuración de WhatsApp actualizada {"configured_fields":{"token":true,"phone_id":true,"webhook_token":true},"user":"debug_user"}
[2026-01-12 14:07:16] [INFO] Configuración de WhatsApp actualizada {"configured_fields":{"token":true,"phone_id":true,"webhook_token":true},"user":"debug_user"}