false, 'error' => 'No message']); exit; } $url = "https://api.telegram.org/bot{$botToken}/sendMessage"; $postData = [ 'chat_id' => $chatId, 'text' => $message, 'parse_mode' => 'HTML' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); error_log("Telegram API Response: " . $response); echo json_encode(['success' => $httpCode === 200, 'response' => $response]); exit; } ?>