Telegram bot weird error: Bad Request: invalid file identifier / specified HTTP URL

I am sending a message to a telegram using a bot.

Using the webhook method.

I am sending file_id by reference. I got file_id from the channel message.

For some files, such as GIF and video format (MP4),

when i use this code:

$url = 'https://api.telegram.org/bot'.token.'/sendVideo?chat_id='.uid."&video=".$file."&caption=" .urlencode($caption); file_get_contents($url); 

I get this error:

 {"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"} 

I really don't know why I understand this. It seems like an accident for errors, because the code depends on what I think.

I am using file_id, which I have from the channel message.

What is the reason for this error? Invalid request: invalid file id / specified HTTP url

  • I searched all related topics, I did not find any good information.
+6
source share
3 answers

There are many possible reasons for this, as indicated in the documentation :

  • Unable to change file type when resubmitted using file_id. that is, a video cannot be sent as a photograph, a photograph cannot be sent as a document, etc.
  • Unable to send thumbnails.
  • Resending the file with file_id will send all its sizes.
  • file_id is unique for each individual bot and cannot be transferred from one bot to another.
+5
source

Your awnser is here @farzad

Submitting file_id
file_id is unique for each individual bot and cannot be transferred from one bot to another.

+4
source

If you send a file (photo, audio, ...) to the bot, you will get a valid file_id for this file (for your bot). It should be safe to use this identifier to send a file, but it does not seem to work for some files (audio, video, ...) !! (It may be a Telegram API error).

You can upload and re-upload the file to your bot to get a new file_id , and this identifier will work.

+1
source

Source: https://habr.com/ru/post/1015623/


All Articles