In Telegram Bot API there's a method "getFile" https://core.telegram.org/bots/api#getfile. I have a bot for testing and have Telegram install on Android. How do I test this method, should I send a file to my bot? If so, then how exactly?
1 Answers
If someone has sent your bot a file (photo, video, document, audio, etc), getFile returns information which allows your bot to download the file. To test this method, do the following:
Use the Android Telegram app to send your bot a photo.
Open a browser, enter in the address bar
https://api.telegram.org/bot<token>/getUpdatesYou should see several
file_ids in the response. These are thumbnails of the photo.Pick a
file_idof your choice. Enter in the browser's address barhttps://api.telegram.org/bot<token>/getFile?file_id=<file_id>Look for
file_pathin the response. It should look something likephoto\/file_22.jpg. The backslash is only to escape the forward slash, so thefile_pathis actuallyphoto/file_22.jpgEnter in the address bar
https://api.telegram.org/file/bot<token>/<file_path>You should see the corresponding thumbnail of the photo.
To download the file programmatically, you may follow the exact same steps as above, or you may use a library such as telepot (Python), which provides a method to download files conveniently, without going through all the above steps.