<?php
function sendTelegramRequest($method, $data) {
    $telegram_token = '7193849734:AAEsCi2GJXnm-sRT0wOS945d1wGC09A0Jjk';
    $url = "https://api.telegram.org/bot$telegram_token/$method";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);

    if ($response === false) {
        error_log("Error al enviar la solicitud cURL: " . curl_error($ch));
    }

    curl_close($ch);

    return json_decode($response, true);
}
function sendMessage($chat_id, $text) {
    $data = array(
        'chat_id' => $chat_id,
        'text' => $text
    );

    return sendTelegramRequest('sendMessage', $data);
}
?>
