通过curl将文件发送到电报bot api

koo*_*ker 2 curl multipartform-data telegram-bot

我尝试过以下方法:

curl -F name=document -F upload=@<path_to_the_file> \ 
     -H "Content-Type:multipart/form-data" \ 
     "https://api.telegram.org/bot<token>/sendDocument?chat_id=<chat_id>"
Run Code Online (Sandbox Code Playgroud)

它回来了 {"ok":false,"error_code":400,"description":"[Error]: Bad Request: there is no document in request"}

我做错了什么?

是关于sendDocument方法的一些文档.

Nic*_*Lee 10

希望这可以帮助.请注意,之前有"bot" <token>.

curl -F document=@"path/to/some.file" https://api.telegram.org/bot<token>/sendDocument?chat_id=<chat_id>
Run Code Online (Sandbox Code Playgroud)

  • 我的错误是我键入了`upload = @ <path_to_the_file>`而不是`document = @ <path_to_the_file>`.再次感谢. (2认同)