Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditMessageMedia method not working #112

Open
MrDarkest opened this issue Dec 20, 2019 · 1 comment
Open

EditMessageMedia method not working #112

MrDarkest opened this issue Dec 20, 2019 · 1 comment
Assignees
Labels

Comments

@MrDarkest
Copy link
Contributor

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);
@unreal4u unreal4u self-assigned this Dec 31, 2019
@unreal4u unreal4u added the bug label Dec 31, 2019
@unreal4u
Copy link
Owner

This should work right out of the box. Will take a look at it once my pc is fixed.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants