1

I want to edit caption of photo, but Im getting error Bad Request: message to edit not found

Code :

<?php
require_once 'Telegram.php';


$telegram = new Telegram('bot:TOken');


$result = $telegram->getData();
$text = $result['message'] ['text'];
$chat_id = $result['message'] ['chat']['id'];
$messageID = $result['message']['message_id'];

  
    $content = array('chat_id' => $chat_id, 'message_id' => $messageID, 'caption' => "wadawd");
    // $content = array('chat_id' => $chat_id, 'text' => $messageID);
    $telegram->editMessageCaption($content);   

Error Log :

============[Date]============
[ 2022-02-28 12:36:58  UTC ] 
==========[Response]==========
ok:         False
error_code:     400
description:        Bad Request: message to edit not found
=========[Sent Data]==========
[ref]
ref.update_id= 3618619
ref.message.message_id= 42
ref.message.from.id= 52868936
ref.message.from.is_bot= false
ref.message.from.first_name= Ramana
ref.message.from.last_name= Owner
ref.message.from.language_code= en
ref.message.chat.id= 52868936
ref.message.chat.first_name= Ramana
ref.message.chat.last_name= Owner
ref.message.chat.type= private
ref.message.date= 1646051816
ref.message.text= esfsef


[ref]
ref.message_id= 
ref.caption= wadawd

============[Trace]===========
#0 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(3228): TelegramErrorLogger::log()
#1 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(111): Telegram->sendAPIRequest()
#2 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(1633): Telegram->endpoint()
#3 /home/onbvbrh08q4z/public_html/captionbot/test.php(15): Telegram->editMessageCaption()
#4 {main}

I'm using this github repo https://github.com/Eleirbag89/TelegramBotPHP

aman_49
  • 116
  • 10

1 Answers1

0

Bots (using api.telegram.org) cannot edit messages of posts made before the bot was added to the channel.

Hence, Telegram Bot Api shows you the error "message to edit not found"

SpEcHiDe
  • 116
  • 1
  • 17
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 19 '22 at 13:07