Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get Message_id from sent message By BOT Telegram?

I program the bot telegram.

I want Get message_id By Bot ,when I sent a message to Group.

My Code is PHP.

$token = "MY_BOT's_TOKEN";

$data = [
    'text' => 'my message here',
    'chat_id' => 'the_chat_id_here'
];

file_get_contents("https://api.telegram.org/bot$token/sendMessage?" . http_build_query($data) );

How Do it?

best regard.

like image 667
hamed hossani Avatar asked Jul 31 '17 07:07

hamed hossani


People also ask

How can I retrieve Telegram bot messages?

Follow the link to your bot by clicking the link that looks like t.me/{yourBotUsername}. This is where you will receive messages.

How do I download a file or photo that was sent to my Telegram bot?

Any file can be downloaded by calling upload. getFile.

How can I delete sent message from Telegram bot?

A message can only be deleted if it was sent less than 48 hours ago. Any such recently sent outgoing message may be deleted. Additionally, if the bot is an administrator in a group chat, it can delete any message.

Can Telegram bot owner see messages?

If privacy mode is disabled, the bot can read all messages sent in a group. If it is enabled, a bot is only receives messages aimed directly at the bot (e.g. using a command or a reply to a message from the bot).


1 Answers

Your file_get_contents call returns a result containing status code and messageId.

$result = file_get_contents("https://api.telegram.org/bot$token/sendMessage?" . http_build_query($data) );
like image 78
tashakori Avatar answered Oct 17 '22 19:10

tashakori