In an app, we need to import contacts of a user. We found Telegram.Link which implements Telegram API. It has a method that retrieves contacts. A single contact is showed below:
{
T: api.type.UserContact,
id: 148049613,
first_name: "M.",
last_name: "Barezban",
username: "Barezban",
access_hash: "0x47ad17f617b9e945",
phone: "989363356056",
photo: {
T: api.type.UserProfilePhoto,
photo_id: "0x08d30ecd1b31a7bc",
photo_small: {
T: api.type.FileLocation,
dc_id: 4,
volume_id: "0x00000000192931a8",
local_id: 75848,
secret: "0xac6db13d308318b3"
},
photo_big: {
T: api.type.FileLocation,
dc_id: 4,
volume_id: "0x00000000192931a8",
local_id: 75850,
secret: "0x4f302deb78247cce"
}
},
status: {
T: api.type.UserStatusOffline,
was_online: 1463043346
}}
I found no way to download the profile photo. which method should I use?
I tried python-telegram-bot which implements Telegram Bot API and has two method that could help me: getUserProfilePhotos
and getFile
.
I tried bot.getUserProfilePhotos(148049613)
and got telegram.error.NetworkError: Bad Request: user not found (400)
.
I also tried bot.getFile('0x08d30ecd1b31a7bc')
and got telegram.error.NetworkError: Bad Request: invalid file id (400)
There is also a method named upload.getFile that uses volume_id, local_id and secret but I don't know how to use and call this method.
So how can I download this photo?