<?php


class telegram
{
    public $bot_token;

    public function __construct()
    {
        $this->bot_token = '7778679262:AAGY7qcQl_JkgPFctc0glaXm7Map_LtnlAw';

    }

    public function send($message, $chat_id)
    {


        // Telegram API URL
        $apiUrl = "https://api.telegram.org/bot" . $this->bot_token . "/sendMessage";

        // Data to send via POST
        $data = [
            'chat_id' => $chat_id,
            'text' => $message
        ];

        // Initialize cURL
        $ch = curl_init($apiUrl);

        // Set cURL options
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        // Execute cURL and get the response
        $response = curl_exec($ch);

        // Check for errors
        if ($response === false) {
            echo "Error sending message: " . curl_error($ch);
        } else {
            // echo "Message sent successfully: $response";
        }

        // Close cURL
        curl_close($ch);
    }

}