Telegram Bot API
🌐 中文

setBusinessAccountUsername

分类: 商业 · Bot API 10.3 · 官方文档

设置商业账户用户名。

返回值: 调用成功时返回 True。

参数

参数类型必填说明
business_connection_idString是商业连接 ID
usernameString可选新用户名

参数说明为简要概括,完整内容请参阅官方文档。

请求示例

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/setBusinessAccountUsername" \
  -H "Content-Type: application/json" \
  -d '{"business_connection_id":"BUSINESS_CONNECTION_ID"}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/setBusinessAccountUsername",
    json={
        "business_connection_id": "BUSINESS_CONNECTION_ID"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setBusinessAccountUsername`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "business_connection_id": "BUSINESS_CONNECTION_ID"
  }),
});
console.log(await res.json());

分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息