Joseph
Joseph

Reputation: 51

Get picture profile user with getUserProfilePhotos in Telegram

I am trying to save the photos of the users of a Telegram bot (a game), using the getUserProfilePhotos method I am testing it with my own id_user. The code:

    def getUserProfilePicture (self, user : User):
        if (user is None) : return None
        requestStr = self.httpbase + self.token + "/getUserProfilePhotos"
        par ={
            "user_id" : user.id, #correct id passed.
            "limit" : 5
        }
        dataReq = requests.post(requestStr, json=par)
        updateData = json.loads(dataReq.content)
        isOk = updateData.get("ok")

And the result (I have also tried with Postman, passing my user id, with and without the limit parameter):

{
    "ok": true,
    "result": {
        "total_count": 0,
        "photos": []
    }
}

This is not the correct result. In my profile I have 3 images. I have tried with other profiles, and the result is the same: 0 images, and an empty array. The link to the API is as follows: link getUserProfilePhotos method

Any idea?

Thank you.

Upvotes: 0

Views: 3089

Answers (1)

CallMeStag
CallMeStag

Reputation: 7030

If your privacy settings say that only your contacts can see your profile pictures, the bot can't see your profile picture (because you can't add it as contact).

Forgot about that when commenting …

Upvotes: 1

Related Questions