java - 如何使用 url 在 tetelgram bot 中下载和发送 .exe 文件?
问题描述
我正在使用 java 开发电报机器人。我想寄一些。exe文件通过url,我已经尝试过 SendDocument 类,它不能使用不同的 url,可能电报 SendDocument 不支持 .exe 格式的文件:
SendDocument sender = new SendDocument();
sender.setChatId(chat_id);
sender.setDocument("https://www.psiphon3.com/psiphon3.exe"); // for example
// I have also used the setNewDocument method . no difference !
try {
sendDocument(sender);
} catch (TelegramApiException a) {
e.printStackTrace();
}
错误是:
Error sending document: [400] Bad Request: wrong file identifier/HTTP URL specified
有人有什么建议吗?是否可以将 .exe 转换为 .zip 然后发送?
解决方案
目前,Telegram“通过 URL 发送”方法不允许发送可执行文件。
文档说:
“在 sendDocument 中,通过 URL 发送当前仅适用于 gif、pdf 和 zip 文件。”
https://core.telegram.org/bots/api#sending-files
将文件下载到 Telegram 服务器后,使用“通过 file_id 发送”。
推荐阅读
- react-native - 使用 redux 过滤列表 - 反应原生
- javascript - 如何在javascript中找到最近的最高千
- android - Volley JsonObjectRequest 响应
- http - 如何确保 lastrequest 成功并继续下一步
- java - 如何使用 GSON 在对象中插入许多 JSON 属性
- php - MY_Email::initialize() 的声明应该与 CI_Email::initialize() 的声明兼容
- c - 架构 x86_64 问题的 Xcode 未定义符号
- r - 具有 Pkg1 <-> Pkg2 <-> Pkg3 等依赖项的 R 包
- r - 将组数据与用户数据匹配并获取组
- sql - 我应该如何设计我的 PosgreSQL 数据库以适应私人、群组和公共聊天?