Telegram Bot API
🌐 Tiếng Việt

giftPremiumSubscription

Danh mục: Thanh toán · Bot API 10.3 · Tài liệu chính thức

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ểuBắt buộcMô tả
user_idIntegerCóID người dùng
month_countIntegerCóSố tháng (1, 3, 6 hoặc 12)
star_countIntegerCóGiá tính bằng Stars: 1000 cho 3 tháng, 1500 cho 6 tháng, 2500 cho 12 tháng
textStringTùy chọnNội dung tin nhắn (0-255)
text_parse_modeStringTùy chọnChế độ định dạng văn bản
text_entitiesArray of MessageEntityTùy chọnMảng JSON MessageEntity

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

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