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 error #738

Closed
texxniks opened this issue Apr 24, 2020 · 1 comment
Closed

editMessageMedia error #738

texxniks opened this issue Apr 24, 2020 · 1 comment

Comments

@texxniks
Copy link

texxniks commented Apr 24, 2020

Bad Request: can't parse InputMedia: Media is not specified

Hello! Tell me a working example of this function! already tried everything


use Telegram\Bot\Api;
use Telegram\Bot\Keyboard\Keyboard;
use Telegram\Bot\Laravel\Facades\Telegram;
use Telegram\Bot\FileUpload\InputFile;
use Telegram\Bot\Objects\InputMedia\InputMedia;
use Telegram\Bot\Objects\InputMedia\InputMediaPhoto;


public $filename = __DIR__ .'/my-photo.jpg';

public function test(){
   $images2 = 'https://cdn.pixabay.com/photo/2017/02/20/19/59/sunset-2083771_960_720.jpg';						
   $res = $this->telegram->editMessageMedia([
		'chat_id' => $chatid,
		'message_id' => 6379,
		'media' => [
				new InputMedia([						  
				'type'   => 'photo',
				'media'   => inputfile::create($images2, $this->filename),
			        'caption'   => '123',
				])
		]					
	]);

}

what am i doing wrong? v3.1.0

@texxniks
Copy link
Author

if you execute the code then everything works

$boturl = "https://api.telegram.org/bot".$this->auth_token."/editMessageMedia";
$bodyobj = ["chat_id" => $chatid, "message_id" => $message_id, "media" => ["type" => "photo", "media" => $images1, "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);

but it doesn’t work like that, writes

Telegram \ Bot \ Exceptions \ TelegramResponseException (400)
Bad Request: can't parse InputMedia: Media is not specified
Previous exceptions

Bad Request: can't parse InputMedia: Media is not specified (400)
$res = $this->telegram->editMessageMedia([
'chat_id' => $chatid,
'message_id' => 6379,
'media' => ["type" => "photo", "media" => $images2, "caption" => $caption, "parse_mode" => "Markdown"]					
]);

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

No branches or pull requests

2 participants