$fullUrl]); $response = curl_exec($ch); curl_close($ch); $results['set'] = json_decode($response, true); } elseif ($_POST['action'] === 'delete') { $ch = curl_init('https://api.telegram.org/bot' . $token . '/deleteWebhook'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $results['delete'] = json_decode($response, true); } elseif ($_POST['action'] === 'check') { $ch = curl_init('https://api.telegram.org/bot' . $token . '/getWebhookInfo'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $results['info'] = json_decode($response, true); } } // Telegram requiere HTTPS obligatoriamente para webhooks $protocol = 'https'; $host = $_ENV['APP_URL'] ?? getenv('APP_URL') ?? $_SERVER['HTTP_HOST']; // Remover protocolo y trailing slash si existen en APP_URL $host = preg_replace('/^https?:\/\//', '', $host); $host = rtrim($host, '/'); $currentUrl = $protocol . '://' . $host . '/telegram/webhook/telegram_bot_webhook.php'; require_once __DIR__ . '/templates/header.php'; ?>
= htmlspecialchars($currentUrl) ?>
URL: = htmlspecialchars($results['info']['result']['url']) ?>
Activo: = $results['info']['result']['url'] ? '✅ Sí' : '❌ No' ?>
Errores: = $results['info']['result']['last_error_message'] ?? 'Ninguno' ?>
No hay webhook configurado
URL base para el webhook (se añadirá automáticamente el token de autenticación):