'How to use editMessageCaption correctly in php Telegram Bot?

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



Solution 1:[1]

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"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SpEcHiDe