telegram-bot-sdk
telegram-bot-sdk copied to clipboard
sendMediaGroup problem
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)formediaproperty. 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.
thanks it's fix my problem