How do I download a file or photo that was sent to my Telegram bot?

前端 未结 6 1646
太阳男子
太阳男子 2020-12-12 18:11

I am using the telegram bot API but I cant see anyway to download a filé that was sent to my bot. I get a hash of the file but dont know what to do with it. Is there any way

6条回答
  •  抹茶落季
    2020-12-12 18:48

    It's just added at September 18, 2015!

    Yay! It's just added at September 18, 2015

    You can use getFile(file_id). This function returns a File object containing file_path. You can download the file through this address:

    https://api.telegram.org/file/bot/

    As mentioned in Telegram Bot API Documentation, the File object will be valid for about one hour. You should call getFile again to get a new File object if the old one expires.

提交回复
热议问题