setPassportDataErrors
告知用户 Telegram Passport 错误。
返回值: 调用成功时返回 True。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | Integer | 是 | 用户 ID |
errors | Array of PassportElementError | 是 | PassportElementError JSON 数组 |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setPassportDataErrors" \
-H "Content-Type: application/json" \
-d '{
"user_id": 123456789,
"errors": [
{
"source": "data",
"type": "personal_details",
"field_name": "first_name",
"data_hash": "DATA_HASH",
"message": "Invalid name"
}
]
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setPassportDataErrors",
json={
"user_id": 123456789,
"errors": [
{
"source": "data",
"type": "personal_details",
"field_name": "first_name",
"data_hash": "DATA_HASH",
"message": "Invalid name"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setPassportDataErrors`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"user_id": 123456789,
"errors": [
{
"source": "data",
"type": "personal_details",
"field_name": "first_name",
"data_hash": "DATA_HASH",
"message": "Invalid name"
}
]
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
getCustomEmojiStickers返回自定义 emoji 贴纸信息。getUserChatBoosts返回用户在聊天中的助力。getBusinessConnection获取商业连接信息。savePreparedInlineMessage保存预先准备的内联消息。verifyUser代表组织认证用户。verifyChat代表组织认证聊天。removeUserVerification移除用户认证。removeChatVerification移除聊天认证。setUserEmojiStatus设置用户的 emoji 状态。savePreparedKeyboardButton为 Mini App 保存键盘按钮。