How do I get the user profile picture of someone using the Telegram bot chat API?
Asked Answered
M

1

11

I'm making a basic Control Panel for managing my Bot with PHP.

Basically I want to display the Profile picture / avatar of the user who is sending message to the bot.

However the user object has no photo_id, so is there way to get the user's avatar?

Moyer answered 15/12, 2017 at 15:32 Comment(0)
P
12

You need to use getUserProfilePhotos method, and then getFile.

For example: Awesome Telegram Bot

Prepositive answered 15/12, 2017 at 15:37 Comment(2)
getFile requires a file_path argument that is not returned from getUserProfilePhotos. If I try to use the file_id as file_path ther I get a "NOT FOUND" error.Florey
ok I fixed it!. You need to call getFile using file_id as argument , you will receive the file_path and then you can download the file using api.telegram.org/file/bot<token>/<file_path>Florey

© 2022 - 2025 — McMap. All rights reserved.