1
私の新しいボットのために私は実際のファイル名を取得する必要があります。 file_idを取得し、「get file」と表示されるダウンロードリンクの生成を要求すると、ファイル名は「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;
は、どのように私は、実際のファイル名を取得することができますか?
あなたの答えDanilに感謝します。通常のメンバーのように電報にmp3ファイルをダウンロードしたいときはファイル名が本当ですか?しかし、ボットを使ってダウンロードすると、その名前は本当のものではありません!私は、トリックでボットでそれをしたい。 –