postStory
Đăng story thay mặt tài khoản doanh nghiệp.
Giá trị trả về: Nếu thành công, trả về Story.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
business_connection_id | String | Có | ID kết nối doanh nghiệp |
content | InputStoryContent | Có | Đối tượng JSON InputStoryContent |
active_period | Integer | Có | Thời gian hiển thị tính bằng giây: 21600, 43200, 86400 hoặc 172800 |
caption | String | Tùy chọn | Chú thích (0-2048) |
parse_mode | String | Tùy chọn | HTML, Markdown, MarkdownV2 |
caption_entities | Array of MessageEntity | Tùy chọn | Mảng JSON MessageEntity |
areas | Array of StoryArea | Tùy chọn | Mảng JSON StoryArea |
post_to_chat_page | Boolean | Tùy chọn | Đăng lên trang chat |
protect_content | Boolean | Tùy chọn | Bảo vệ nội dung |
Ví dụ request
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());
Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên
Phương thức liên quan
editStoryChỉnh sửa story thay mặt tài khoản doanh nghiệp.deleteStoryXóa story thay mặt tài khoản doanh nghiệp.repostStoryĐăng lại story giữa các tài khoản doanh nghiệp (Bot API 9.3).