postStory
代表商业账户发布动态。
返回值: 调用成功时返回 Story。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
business_connection_id | String | 是 | 商业连接 ID |
content | InputStoryContent | 是 | InputStoryContent JSON 对象 |
active_period | Integer | 是 | 有效期(秒):21600、43200、86400 或 172800 |
caption | String | 可选 | 说明文字(0-2048) |
parse_mode | String | 可选 | HTML、Markdown 或 MarkdownV2 |
caption_entities | Array of MessageEntity | 可选 | MessageEntity JSON 数组 |
areas | Array of StoryArea | 可选 | StoryArea JSON 数组 |
post_to_chat_page | Boolean | 可选 | 发布到聊天资料页 |
protect_content | Boolean | 可选 | 保护内容 |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/postStory" \
-H "Content-Type: application/json" \
-d '{
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/postStory",
json={
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/postStory`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
editStory代表商业账户编辑动态。deleteStory代表商业账户删除动态。repostStory在商业账户之间转发动态 (Bot API 9.3)。