Home » Php » Telegram Bot sends same message many times PHP

Telegram Bot sends same message many times PHP

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am writing a telegram to the php bot, it works fine, but it sends the same message many times, it needs to be sent once, can anyone help me? here is my code

function chat_telegram( )
{
    $token = <token>;
    $telegram = "https://api.telegram.org/bot" . $token;
    $query = http_build_query([
        'chat_id' => <chat_id>,
        'text' => 'I love pizza'
    ]);

    $response = file_get_contents( $telegram . '/sendMessage?' . $query );
    return $response;
}
How to&Answers: