Telegram Bot API
🌐 中文

transferGift

分类: 支付 · Bot API 10.3 · 官方文档

将唯一礼物转让给其他用户。

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

参数

参数类型必填说明
business_connection_idString是商业连接 ID
owned_gift_idString是已拥有礼物 ID
new_owner_chat_idInteger是新所有者的聊天 ID
star_countInteger可选转让所需的 Stars 数量

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

请求示例

curl

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

Python

import requests

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

JavaScript

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

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