giftPremiumSubscription
Tặng gói đăng ký Telegram Premium.
Giá trị trả về: Nếu thành công, trả về True.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
user_id | Integer | Có | ID người dùng |
month_count | Integer | Có | Số tháng (1, 3, 6 hoặc 12) |
star_count | Integer | Có | Giá tính bằng Stars: 1000 cho 3 tháng, 1500 cho 6 tháng, 2500 cho 12 tháng |
text | String | Tùy chọn | Nội dung tin nhắn (0-255) |
text_parse_mode | String | Tùy chọn | Chế độ định dạng văn bản |
text_entities | Array of MessageEntity | Tùy chọn | Mảng JSON MessageEntity |
Ví dụ request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/giftPremiumSubscription" \
-H "Content-Type: application/json" \
-d '{"user_id":123456789,"month_count":3,"star_count":100}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/giftPremiumSubscription",
json={
"user_id": 123456789,
"month_count": 3,
"star_count": 100
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/giftPremiumSubscription`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"user_id": 123456789,
"month_count": 3,
"star_count": 100
}),
});
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
sendInvoiceGửi hóa đơn thanh toán.createInvoiceLinkTạo liên kết thanh toán.refundStarPaymentHoàn tiền một khoản thanh toán bằng Telegram Stars.sendGiftGửi quà tặng cho người dùng hoặc chat.getMyStarBalanceTrả về số dư Telegram Stars của bot.getStarTransactionsTrả về các giao dịch Telegram Stars của bot.editUserStarSubscriptionHủy hoặc gia hạn gói đăng ký Telegram Stars.answerShippingQueryTrả lời truy vấn giao hàng.answerPreCheckoutQueryTrả lời truy vấn pre-checkout.getAvailableGiftsTrả về các quà tặng mà bot có thể gửi.getUserGiftsTrả về quà tặng của người dùng.getChatGiftsTrả về quà tặng của chat.