O
O
okovalev2020-06-09 06:26:14
PHP
okovalev, 2020-06-09 06:26:14

How to send a file in Telgram bot by id?

https://core.telegram.org/bots/api#sending-files
https://github.com/irazasyed/telegram-bot-sdk/blob...

The telegram API says you can use file_id to send a file.
The library method says that you can actually send a file by file_id.
The link to the file is sent without problems.

$url = 'files/video.MP4';
$response = $telegram->sendDocument(['chat_id' => $chat_id, 'document' => InputFile::create($url)]);

If I try to send by id
$response = $telegram->sendDocument([
    'chat_id' => $chat_id,
    'document' => 'BAACAgIAAxkDAAPLXt765mi26pbaCsuwarR-4Vpg1GPlKR3DgfhB75rgaBA'
]);

Error pops
5edf0129c29a3301477586.png
up: Wrong file type. Why did I not understand and how to?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question