giftPremiumSubscription
Gifts a Telegram Premium subscription to the given user
Gifts a Telegram Premium subscription to the given user. Returns True on success.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | Integer | Yes | Unique identifier of the target user who will receive a Telegram Premium subscription |
month_count | Integer | Yes | Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 |
star_count | Integer | Yes | Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months |
text | String | Optional | Text that will be shown along with the service message about the subscription; 0-128 characters |
text_parse_mode | String | Optional | Mode for parsing entities in the text. See formatting options for more details. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", "custom_emoji", and "date_time" are ignored. |
text_entities | Array of MessageEntity | Optional | A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", "custom_emoji", and "date_time" are ignored. |
Example
PHP — Call giftPremiumSubscription on Botlify Cloud
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN = getenv('BOT_TOKEN'); // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME = getenv('BOT_USERNAME'); // Bot username without @
$resp = bot('giftPremiumSubscription', [
'user_id' => $userId,
'month_count' => 'value',
'star_count' => 'value',
]);
if ($resp['ok'] ?? false) {
$result = $resp['result']; // handle the response
}Botlify Cloud Runtime
Credentials are auto-injected in
Credentials are auto-injected in
.env — always load them with getenv(): BOT_TOKEN, ADMIN_CHAT_ID, BOT_USERNAME. Main database: database.db (SQLite, WAL mode). Runtime errors: error.log. Quick test: send to $ADMIN_CHAT_ID. Full details: Runtime Reference.