Answer the question
In order to leave comments, you need to log in
How to use editMessageMedia in telegram bot to change images?
Please share an example of using editMessageMedia. It is not possible to correctly form a request and send via curl.
I learned to edit the text through editMessageText, but it does not work with the file.
Answer the question
In order to leave comments, you need to log in
The wording is the same, only the photo needs to be transmitted in JSON-serialized form.
$photo = [ 'type'=> 'photo',
'media' => 'здесь параметры картинки file_id или url',
'caption' => 'ТЕКСТ',
'parse_mode' => 'html'
]
$fields = ['chat_id' => 'id чата ',
'message_id' => 'message_id', //id сообщения
'media' => json_encode($photo),
'reply_markup' => json_encode($buttons)]; // если есть кнопки
// отправляем методом CURL
$ch = curl_init('https://api.telegram.org/bot' . $token . '/editMessageMedia');
curl_setopt_array($ch, array(
CURLOPT_POST => count($fields),
CURLOPT_POSTFIELDS => http_build_query($fields),
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => 10
));
$r = json_decode(curl_exec($ch), true);
curl_close($ch);
return $r;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question