Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

EditMessageMedia method not working #112

Description

@MrDarkest

Which version are you using?

3.5.0

Description of problem

EditMessageMedia method doesn't work.

I've tried with this code:

$editMessageMedia = new EditMessageMedia();
$editMessageMedia->chat_id = "@channelname"
$editMessageMedia->message_id = $message_id;
$photo = new Photo();
$photo->media = "https://my-host/image.png"
$photo->caption = "A caption";
$photo->parse_mode = "Markdown";
$editMessageMedia->media = $photo;
$promise = $tgLog->performApiRequest($editMessageMedia);
$promise->then(
	function () {
        },
        function (\Exception $exception) {
	       error_log($exception->getMessage());
       }
);
$loop->run();

But it always fails with the error: "Bad Request: can't parse InputMedia: Media is not specified".

With the same parameters the classic POST call to telegram api with a JSON body works fine.

$boturl = "https://api.telegram.org/bot".TELEGRAM_BOT_KEY."/editMessageMedia";
$bodyobj = ["chat_id" => $chat_id, "message_id" => $message_id, "media" => ["type" => "photo", "media" => $url, "caption" => $caption, "parse_mode" => "Markdown"]];
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,            $boturl );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,           1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,     json_encode($bodyobj) ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: application/json')); 

$result=curl_exec ($ch);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions