[ 'method' => 'GET', 'header' => "Authorization: Bearer {$newToken}\r\n" ] ]); $testResponse = @file_get_contents($testUrl, false, $context); $httpCode = 200; if (isset($http_response_header)) { foreach ($http_response_header as $header) { if (strpos($header, 'HTTP/') === 0) { $httpCode = (int) substr($header, 9, 3); } } } if ($httpCode !== 200) { $error = 'No se puede validar el Phone Number ID. Verifique que sea correcto y que tenga permisos.'; } else { // Actualizar en base de datos $pdo = createDbConnection(); // Verificar si existe la tabla system_config $tableExists = $pdo->query("SHOW TABLES LIKE 'system_config'")->rowCount() > 0; if ($tableExists) { // Actualizar Phone Number ID $stmt = $pdo->prepare(" INSERT INTO system_config (config_key, config_value, updated_at) VALUES (?, ?, NOW()) ON DUPLICATE KEY UPDATE config_value = VALUES(config_value), updated_at = NOW() "); $stmt->execute(['whatsapp_phone_number_id', $newPhoneId]); // Actualizar Token $stmt->execute(['whatsapp_token', $newToken]); $message = "✅ Configuración actualizada correctamente. Phone Number ID: {$newPhoneId}"; // Refrescar la página para mostrar la nueva configuración header("Location: " . $_SERVER['PHP_SELF'] . "?updated=1"); exit; } else { $error = 'La tabla system_config no existe. Ejecute la instalación primero.'; } } } catch (Exception $e) { $error = 'Error al actualizar configuración: ' . $e->getMessage(); } } } } // Si se redirigió después de actualizar if (isset($_GET['updated'])) { $message = "✅ Configuración actualizada correctamente."; } ?> Corrección Phone Number ID - WhatsApp Bot

Corrección Phone Number ID Problemático

Problema Detectado

El sistema está intentando usar el Phone Number ID:

⚠️ Este ID está generando el error: "Object with ID '858157464051987' does not exist, cannot be loaded due to missing permissions, or does not support this operation"

Cómo obtener el Phone Number ID correcto:
  1. Ve a Facebook for Developers
  2. Selecciona tu app de WhatsApp Business
  3. En el menú izquierdo, ve a "WhatsApp" → "API Setup"
  4. Copia el "Phone Number ID" que aparece ahí
  5. También copia tu "Access Token" si ha cambiado
Debe empezar con EAA
Solo números, 10-20 dígitos