I used this GitHub package to construct my Telegram bot. I want to edit my sent message from the bot. I get confused because I think everything is right!!!
$content = array('chat_id' => $chat_id, 'text' => "
some text
" );
// sending message, it will return Telegram JSON's reply, contains message_id which is used further to //edit sent message (https://core.telegram.org/bots/api#message)
$newmess= $telegram->sendMessage($content);
// in order to edit the message we should provide the //(https://core.telegram.org/bots/api#editmessagetext) keys
// message_id is achieved by the last message sent ($newmess the message_id key)
$content = array('chat_id' => $newmess['chat']['id'],'message_id'=>$newmess['message_id'],'text' => "
some text 2
");
$telegram->editMessageText($content);
but when I saw the logs, $newmess[‘message_id’] is empty! according to the Telegram docs, if message sent success, the response contains keys such as message_id ! (https://core.telegram.org/bots/api#message)
here is the log :
ok: False
error_code: 400
description: Bad Request: message identifier is not specified
2
Answers
solved: $newmess['result']['message_id'] result key is required.
It is also possible to get message to edit not found error when the user clicks on the inline keyboard button after some time. In that case, an error happens due to the removed message. Telegram can remove your message from the server at any time (related to Bot API). In that case, you will receive a malformed response.