user3416269
user3416269

Reputation: 375

How to send a message to a public Telegram channel by php?

Is it possible to send a message to a public Telegram channel by API as admin? I mean is it possible to send e.g. a video to a public Telegram channel by using e.g. php?

Upvotes: 9

Views: 26593

Answers (1)

Saeid Tahmuresi
Saeid Tahmuresi

Reputation: 876

You can create a telegram bot and add it to your channel as admin. Then use @yourchannel as chat_id in your telegram bot for sending messages to your channel. As an example in php:

<?php
$botToken = "yourbottoken";
$chat_id = "@yourchannel";
$message = "your message";
$bot_url    = "https://api.telegram.org/bot$botToken/";
$url = $bot_url."sendMessage?chat_id=".$chat_id."&text=".urlencode($message);
file_get_contents($url);
?>

Upvotes: 30

Related Questions