telegram-bot-sdk icon indicating copy to clipboard operation
telegram-bot-sdk copied to clipboard

sendMediaGroup problem

Open aleksandr-zhulaev opened this issue 4 years ago • 1 comments
trafficstars

$files[] = [
    'type' => 'photo',
    'media' => $file,
    'caption' => '...'
];

$bot->sendMediaGroup([
    'chat_id' => $user->telegram_id,
    'media' => json_encode($media),
    'disable_notification' => false
]);

An error occured:

A path to local file, a URL, or a file resource should be uploaded using Telegram\Bot\FileUpload\InputFile::create($pathOrUrlOrResource, $filename) for media property. Please view docs for example.

Probably the problem is here: https://github.com/irazasyed/telegram-bot-sdk/blob/439552ebbbbbb9051f435c6556bb1c2ba5771425/src/Traits/Http.php#L343

If we transfer json,

(! $params[$inputFileField] instanceof InputFile) = true
(is_string($params[$inputFileField]) && ! $this->is_json($params[$inputFileField])) = false
(! $params[$inputFileField] instanceof InputFile) || (is_string($params[$inputFileField]) && ! $this->is_json($params[$inputFileField])) = true

Probably the more correct solution was

if ((! $params[$inputFileField] instanceof InputFile) && (is_string($params[$inputFileField]) && ! $this->is_json($params[$inputFileField]))) {

This solved my problem.

aleksandr-zhulaev avatar Feb 26 '21 15:02 aleksandr-zhulaev

thanks it's fix my problem

mrjavadseydi avatar Aug 31 '21 07:08 mrjavadseydi