I need to get the profile picture of a channel in Telegram. According to this doc:
https://core.telegram.org/bots/api
I first try to use getChat to get the basic information about a channel . Which I get successfully. It gives me a json like this:
{"ok":true,"result":{"id":-1001003587533,"title":"u06a9u0627u0641","username":"kafiha","type":"channel"}}
After this I try to use ‘getUserProfilePhotos’ to get the profile photo. But I can’t get it to work because it responds with error when I either pass the id I got from the last request or the channeld username (@channelName).
Do you know how can I accomplish this using Bot API for Telegram?
2
Answers
It’s not available now in Bot API. getUserProfilePhotos method require
user_id
parameter, notchat_id
as you tryed.After using
getChat(chat_id)
, if the channel has got a photo, it returns an object which includes a photo object, then you can getphoto.big_file_id
and usegetFile(photo.big_file_id)
to get the full link of the downloadable channel photo. ifgetChat(chat_id)
returned object does not include a photo, then it means channel does not have a profile photoHere is more info on Telegram’s documentation. https://core.telegram.org/bots/api#getfile