skip to Main Content

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


  1. It’s not available now in Bot API. getUserProfilePhotos method require user_id parameter, not chat_id as you tryed.

    Login or Signup to reply.
  2. After using getChat(chat_id), if the channel has got a photo, it returns an object which includes a photo object, then you can get photo.big_file_id and use getFile(photo.big_file_id) to get the full link of the downloadable channel photo. if getChat(chat_id) returned object does not include a photo, then it means channel does not have a profile photo

    Here is more info on Telegram’s documentation. https://core.telegram.org/bots/api#getfile

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search