getUserProfilePhotos
返回用户的头像列表。
返回值: 调用成功时返回 UserProfilePhotos。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | Integer | 是 | 用户 ID |
offset | Integer | 可选 | 分页偏移量 |
limit | Integer | 可选 | 照片数量(1-100,默认 100) |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/getUserProfilePhotos" \
-H "Content-Type: application/json" \
-d '{"user_id":123456789}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/getUserProfilePhotos",
json={
"user_id": 123456789
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getUserProfilePhotos`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"user_id": 123456789
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
getMe返回机器人信息。getMyCommands返回机器人当前的命令列表。setMyCommands设置机器人的命令列表。deleteMyCommands删除机器人命令。getMyName返回机器人的名称。setMyName设置机器人的名称。getMyDescription返回机器人的描述。setMyDescription设置机器人的描述。getMyShortDescription返回机器人的简短描述。setMyShortDescription设置机器人的简短描述。setMyProfilePhoto设置机器人的头像。removeMyProfilePhoto移除机器人的头像。