How to download full size photo using Telegram Bot API uploaded from user

你说的曾经没有我的故事 提交于 2020-08-27 21:27:03

问题


I'm working on a telegram bot and I need to download photo, audio, video sent by user to the bot. Using the only path returned by the get file method I only get a thumbnail. In fact the only result of the get file method contains a really tiny value for the file size. I can't figure out where the problem is. The photos are normally sent by message as photo (not as file).


回答1:


first you should download the photo with this api to your bot

https://api.telegram.org/bot<token>/getfile?file_id={the file_id of the photo you want to download}

then it returns you a response of a File which has an attribute named file_path

then using the file_path you can download the photo full size using this

https://api.telegram.org/file/bot<token>/<file_path>

all of this is based on official documentation found here . Telegram API Doc



来源:https://stackoverflow.com/questions/39052361/how-to-download-full-size-photo-using-telegram-bot-api-uploaded-from-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!