Telegram Bot API
🌐 中文

setBusinessAccountGiftSettings

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

配置商业账户的礼物设置。

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

参数

参数类型必填说明
business_connection_idString是商业连接 ID
show_gift_buttonBoolean是显示礼物按钮
accepted_gift_typesAcceptedGiftTypes是AcceptedGiftTypes JSON 对象

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

请求示例

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/setBusinessAccountGiftSettings" \
  -H "Content-Type: application/json" \
  -d '{
  "business_connection_id": "BUSINESS_CONNECTION_ID",
  "show_gift_button": true,
  "accepted_gift_types": {
    "unlimited_gifts": true,
    "limited_gifts": true,
    "unique_gifts": true,
    "premium_subscription": true,
    "gifts_from_channels": true
  }
}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/setBusinessAccountGiftSettings",
    json={
        "business_connection_id": "BUSINESS_CONNECTION_ID",
        "show_gift_button": True,
        "accepted_gift_types": {
            "unlimited_gifts": True,
            "limited_gifts": True,
            "unique_gifts": True,
            "premium_subscription": True,
            "gifts_from_channels": True
        }
    },
    timeout=30,
)
print(resp.json())

JavaScript

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

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