sendPaidMedia
发送付费媒体 (Bot API 8.0+)。
返回值: 调用成功时返回 Message。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
business_connection_id | String | 可选 | 商业连接 ID |
chat_id | Integer or String | 是 | 聊天 ID 或 @username |
message_thread_id | Integer | 可选 | 论坛话题 ID |
direct_messages_topic_id | Integer | 可选 | 私信话题 ID (Bot API 10.0) |
star_count | Integer | 是 | Telegram Stars 数量(1-2500) |
media | Array of InputPaidMedia | 是 | InputPaidMedia JSON 数组 |
payload | String | 可选 | 支付有效载荷 |
caption | String | 可选 | 说明文字(0-1024) |
parse_mode | String | 可选 | HTML、Markdown 或 MarkdownV2 |
caption_entities | Array of MessageEntity | 可选 | MessageEntity JSON 数组 |
show_caption_above_media | Boolean | 可选 | 在媒体上方显示说明文字 |
disable_notification | Boolean | 可选 | 静默发送 |
protect_content | Boolean | 可选 | 保护内容 |
allow_paid_broadcast | Boolean | 可选 | 允许付费广播 |
suggested_post_parameters | SuggestedPostParameters | 可选 | SuggestedPostParameters JSON 对象 |
reply_parameters | ReplyParameters | 可选 | ReplyParameters JSON 对象 |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | 可选 | JSON 对象:InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendPaidMedia" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"star_count": 100,
"media": [
{
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
]
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendPaidMedia",
json={
"chat_id": 123456789,
"star_count": 100,
"media": [
{
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendPaidMedia`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"star_count": 100,
"media": [
{
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
]
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
sendPhoto发送照片。sendVideo发送视频。sendDocument发送文件。sendAudio发送音频。sendAnimation发送动画(GIF)。sendSticker发送贴纸。sendVoice发送语音消息。sendVideoNote发送视频消息(圆形视频)。sendMediaGroup发送一组媒体(相册)。sendDice发送骰子。sendLivePhoto发送实况照片(照片 + 视频,Bot API 10.0)。