Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive images with the Telegram API?

Is it possible to receive images (and store it on the server) which was sent by any user to the bot?

If a image was sent, I receive this JSON post. This is a link to the Telegram Bot-API description. I don't know if it's possible to receive the whole image or not: https://core.telegram.org/bots/api#available-types

{"update_id":XXXXX,
"message":{"message_id":2222,"from":{"id":XXXXX,"first_name":"Christoph","last_name":"XXXXX"},"chat":{"id":XXXXX,"first_name":"Christoph","last_name":"XXXXX"},"date":1435704055,"forward_from":{"id":XXXXX,"first_name":"Christoph","last_name":"XXXXX"},"forward_date":1435703471,"photo":[{"file_id":"AgADAgADmaoxG9KknwF4O978o3EMqb_EWSoABI5s-WWq46dqiR0AAgI","file_size":998,"width":51,"height":90},{"file_id":"AgADAgADmaoxG9KknwF4O978o3EMqb_EWSoABHax4HvxYqktiB0AAgI","file_size":9912,"width":180,"height":320},{"file_id":"AgADAgADmaoxG9KknwF4O978o3EMqb_EWSoABNzzDwp3sT2whx0AAgI","file_size":41020,"width":450,"height":800},{"file_id":"AgADAgADmaoxG9KknwF4O978o3EMqb_EWSoABE0Gg-AefJ7Yhh0AAgI","file_size":66058,"width":720,"height":1280}]}}
like image 882
C.E. Avatar asked Jul 01 '15 21:07

C.E.


People also ask

How can I download image from Telegram API?

From telegram's docs: On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour.

How can I download a file from Telegram API?

Downloading a file from Telegram is done in two steps: Get file information with getFile method. Resulting File object contains FilePath from which we can download the file. Downloading the file.

How can I access Telegram API?

Log in to your Telegram core: https://my.telegram.org. Go to "API development tools" and fill out the form. You will get basic addresses as well as the api_id and api_hash parameters required for user authorization. For the moment each number can only have one api_id connected to it.


1 Answers

Telegram support download file now with getFile:

You can see it in the api documentation: https://core.telegram.org/bots/api#getfile

like image 82
Samuel Surya Avatar answered Sep 19 '22 06:09

Samuel Surya