【发布时间】:2017-06-10 22:29:39
【问题描述】:
我正在尝试从 Telegram BOT 发送语音消息,但没有成功。
作为概念证明,我尝试使用curl:
#!/bin/bash
TOKEN=$(cat .token)
CHAT=$(cat .chat)
URL="http://server2.mbrt.it:8080/static/foo.ogg"
curl "https://api.telegram.org/bot$TOKEN/sendVoice?chat_id=$CHAT&voice=$URL"
但我不断得到:
{"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"}
我确定令牌和聊天 ID 都是正确的,因为我可以使用 sendAudio 方法发送音频(发送 mp3 文件)。我使用的 URL 是公开的,任何 PC 上的wget 都会下载该文件。
HTTP 标头也是正确的 AFAIK(注意 Content-Type 标头):
$ curl -v http://server2.mbrt.it:8080/static/foo.ogg >/dev/null
< HTTP/1.1 200 OK
< Server: nginx/1.10.3
< Date: Fri, 09 Jun 2017 14:14:11 GMT
< Content-Type: audio/ogg
< Content-Length: 5881
< Last-Modified: Thu, 08 Jun 2017 23:23:21 GMT
< Connection: keep-alive
< ETag: "5939dc69-16f9"
< Accept-Ranges: bytes
我的猜测是我的编码在某种程度上是错误的:
$ file foo.ogg
foo.ogg: Ogg data, Opus audio,
但我尝试使用ffmpeg、opusenc 和oggenc 对其进行编码。在所有情况下,我在发送时都会收到相同的错误。
我不知道自己做错了什么。
【问题讨论】:
标签: telegram-bot