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

匿名 (未验证) 提交于 2019-12-03 08:42:37

问题:

I am sending message to telegram channel using bot.

With using webhook method.

I'm sending file_id via the link. I got the file_id from a channel post.

For some files like GIF & 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 such this error :

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

I really don't know why i get this, It's like this is random for errors, Because the code is depended to nothing i guess.

I use file_id that i've got from a channel's post.

What is the reason of that error? Bad Request: wrong file identifier/HTTP URL specified

  • I've searched all related topics, I've found NO good information .

回答1:

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

  • It is not possible to change the file type when resending by file_id. i.e. a video can't be sent as a photo, a photo can't be sent as a document, etc.
  • It is not possible to resend thumbnails.
  • Resending a photo by file_id will send all of its sizes.
  • file_id is unique for each individual bot and can't be transferred from one bot to another.


回答2:

Your Awnser is here @farzad

Sending by file_id
file_id is unique for each individual bot and can't be transferred from one bot to another.



回答3:

If you forward a file (photo, audio, ...) to a bot, you will get a valid file_id for this file (for your bot). It should be safe to use this id to send then file, but it seems it dosen't work for some files (audio, video, ...)!! (May be a Telegram API bug).

You can download and reupload the file to your bot, to get a new file_id and this id will work.



回答4:

Go to @webpagebot and send him an URL to the file. The telegram's cache will be invalidated, and this should work. Seems that it is a bug on the server.

In my case I couldn't upload an image (as sticker), http://.../blabla.webp not via telegram app, not via telegram bot API.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!