1
對於我的新機器人,我需要獲取真實的文件名。 當我得到file_id並請求生成與「獲取文件」命令的下載鏈接時,文件名看起來像「file_370.mp3」,但真正的文件名是:「michaeljackson.mp3」。如何通過file_id在電文中獲取文件名
我想這代碼:
$mp3name = $result['message']['audio']['title'];
$mp3fileid = $result['message']['audio']['file_id'];
file_get_contents($url."/sendaudio?chat_id=118718802&audio=$mp3fileid&performer=awaperformer&title=awatitle");
$bot_url = "https://api.telegram.org/bot".$botToken;
$file_path_gen_url = $bot_url."/getfile?file_id=".$mp3fileid;
// file_get_contents($url."/sendmessage?chat_id=118718802&text=lastfileid:filegen:$file_path_gen_url");
$file_path_result = file_get_contents($file_path_gen_url);
// echo "last file id: $last_file_id <br>";
$file_path_result = json_decode($file_path_result, TRUE);
$file_path = $file_path_result['result']['file_path'];
// echo "file_path: $file_path <br>";
$file_url = "https://api.telegram.org/file/bot".$botToken."/".$file_path;
我怎樣才能得到真正的文件名?
謝謝你的回答丹尼爾。當我們想要像普通會員文件名稱一樣在電報中下載mp3文件是真實的!但是當我們用bot下載它的名字並不真實!我想要通過機器人來做到這一點。 –