Telegram Bot API
🌐 中文

repostStory

分类: 动态 · Bot API 10.3 · 官方文档

在商业账户之间转发动态 (Bot API 9.3)。

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

参数

参数类型必填说明
business_connection_idString是商业连接 ID
from_chat_idInteger是发布该动态的聊天 ID
from_story_idInteger是要转发的动态 ID
active_periodInteger是有效期(秒):21600、43200、86400 或 172800
post_to_chat_pageBoolean可选动态过期后仍可访问
protect_contentBoolean可选保护内容,禁止转发和截图

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

请求示例

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/repostStory" \
  -H "Content-Type: application/json" \
  -d '{
  "business_connection_id": "BUSINESS_CONNECTION_ID",
  "from_chat_id": 123456789,
  "from_story_id": 1,
  "active_period": 86400
}'

Python

import requests

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

JavaScript

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

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