2017-07-31 132 views
2

我編程bot電報。如何從發送的郵件中獲取Message_id By BOT Telegram?

我想得到message_id通過Bot,當我發送消息給Group。

我的代碼是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)); 

這是怎麼回事?

最好的方面。

+1

分享您的部分代碼並指定您正在使用的庫。 – tashakori

+0

我改變了我的答案。 –

+1

我不是php專家,但請按照下列步驟操作: $ response = file_get_contents(「https://api.telegram.org/bot$token/sendMessage?」。http_build_query($ data)); echo $ response; 現在你知道了json響應的結構,然後編寫一個代碼來解析json結果並提取messageID。 – tashakori

回答

2

您的file_get_contents調用返回包含狀態碼和messageId的結果。

$result = file_get_contents("https://api.telegram.org/bot$token/sendMessage?" . http_build_query($data)); 
相關問題