【发布时间】:2016-05-04 02:27:22
【问题描述】:
我在 php telegram bot 中的 sendAudio() 函数有问题。
if (strtoupper($text) == "MUSIC") {
$voice = curl_file_create('audio.ogg');
$content = array('chat_id' => $chat_id, 'audio' => $voice);
$telegram->sendAudio($content);
}
这不适用于 9 秒或更长的音频长度。我也尝试过 .mp3 但没有。音频长度为 6 秒或更短的相同功能可以工作。我查看了文档,它说只有 50MB 文件受到限制。请帮忙。 这是我的 $telegram。
include("Telegram.php");
$bot_id = "xxxxxxx:yyyyyyyy_mytoken";
$telegram = new Telegram($bot_id);
这里是 Telegram.php:
class Telegram {
private $bot_id = "mytoken";
private $data = array();
private $updates = array();
public function __construct($bot_id) {
$this->bot_id = $bot_id;
$this->data = $this->getData();
}
public function endpoint($api, array $content, $post = true) {
$url = 'https://api.telegram.org/bot' . $this->bot_id . '/' . $api;
if ($post)
$reply = $this->sendAPIRequest($url, $content);
else
$reply = $this->sendAPIRequest($url, array(), false);
return json_decode($reply, true);
}
public function sendAudio(array $content) {
return $this->endpoint("sendAudio", $content);
}
【问题讨论】:
标签: php audio telegram telegram-bot