Php – Telegram BotApi, Send message to multiple chat_id

ajaxjsonPHPtelegramtelegram-bot

I was wondering if I could send a message with my bot on telegram bot api, to multiple chat_id, but I cant figure it out. that's totally because of telegram apis are so hard to understand.
I have used this for send a message to one chat_id:

https://api.telegram.org/botTOKKEN/sendMessage?chat_id=xxxxxxx&text=Hi+John

Best Answer


There is no way to make bot to sendMessage to multiple chat id but there is a trick that can fix it for now :)
Why not sending each chat id a message ?!
Let's look at this example in PHP :

<?php
$message = "Hi John";
$chatIds = array("xxx","xxx","xxx"); // AND SOME MORE
foreach($chatIds as $chatId) {
    // Send Message To chat id
    file_get_contents("https://api.telegram.org/botTOKKEN/sendMessage?chat_id=$chatId&text=".$message);
}
?>
Related Topic