funcional
This commit is contained in:
@@ -31,9 +31,9 @@ try {
|
||||
// 1. Verificar configuración básica
|
||||
$diagnostic['config_status'] = [
|
||||
'phone_number_id' => !empty($whatsappConfig['phone_number_id']),
|
||||
'access_token' => !empty($whatsappConfig['access_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) {
|
||||
@@ -60,9 +60,9 @@ try {
|
||||
|
||||
// 3. Test básico de API (solo si hay configuración completa)
|
||||
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 = [
|
||||
'Authorization: Bearer ' . $whatsappConfig['access_token'],
|
||||
'Authorization: Bearer ' . $whatsappConfig['whatsapp_token'],
|
||||
'Content-Type: application/json'
|
||||
];
|
||||
|
||||
@@ -88,7 +88,9 @@ try {
|
||||
} else {
|
||||
$diagnostic['api_status'] = [
|
||||
'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 {
|
||||
@@ -122,7 +124,7 @@ try {
|
||||
// Agregar compatibilidad con la estructura esperada en index.php
|
||||
$configComplete = $diagnostic['config_status']['complete'];
|
||||
$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;
|
||||
|
||||
foreach ($configFields as $field) {
|
||||
|
||||
@@ -489,9 +489,10 @@ class SimpleWhatsAppManager {
|
||||
if (!data) return;
|
||||
|
||||
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: 'webhook-token', value: data.webhook_verify_token },
|
||||
{ id: 'api-url', value: data.api_url },
|
||||
{ id: 'business-name', value: data.business_name },
|
||||
{ id: 'welcome-message', value: data.welcome_message }
|
||||
];
|
||||
@@ -514,6 +515,7 @@ class SimpleWhatsAppManager {
|
||||
token: document.getElementById('whatsapp-token').value,
|
||||
phone_number_id: document.getElementById('phone-number-id').value,
|
||||
webhook_verify_token: document.getElementById('webhook-token').value,
|
||||
api_url: document.getElementById('api-url').value,
|
||||
business_name: document.getElementById('business-name').value,
|
||||
welcome_message: document.getElementById('welcome-message').value
|
||||
};
|
||||
|
||||
+2
-2
@@ -637,9 +637,9 @@ function saveWhatsAppConfigToDB($whatsappConfig) {
|
||||
*/
|
||||
function getWhatsAppConfigFromDB() {
|
||||
return [
|
||||
'token' => getConfigFromDB('whatsapp_token', ''),
|
||||
'whatsapp_token' => getConfigFromDB('whatsapp_token', ''),
|
||||
'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', ''),
|
||||
'business_name' => getConfigFromDB('business_name', ''),
|
||||
'welcome_message' => getConfigFromDB('welcome_message', ''),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Página principal del sistema WhatsApp Bot
|
||||
* Fecha: 13 de noviembre de 2025
|
||||
@@ -29,6 +30,7 @@ try {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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/diagnostic.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Sidebar -->
|
||||
<nav class="sidebar">
|
||||
@@ -470,6 +473,10 @@ try {
|
||||
<label class="form-label">Webhook Verify Token</label>
|
||||
<input type="text" class="form-control" id="webhook-token" placeholder="Token de verificación del webhook">
|
||||
</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 class="mb-4">
|
||||
@@ -738,4 +745,5 @@ try {
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -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"}
|
||||
Reference in New Issue
Block a user