TelegramPHP Documentation

FileApi

This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.

Do not edit it by hand - run composer spec:build instead.

Locating and uploading files.

Mixed into Telegram through Methods. Every method is named exactly as the Bot API names it, takes exactly the fields the Bot API documents (use named arguments for the optional ones), and resolves with the hydrated result.

Tags
link
https://core.telegram.org/bots/api
since

v10.3

Table of Contents

Methods

getFile()  : PromiseInterface<string|int, File>
Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned.
uploadStickerFile()  : PromiseInterface<string|int, File>
Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success.

Methods

getFile()

Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned.

public getFile(string $file_id) : PromiseInterface<string|int, File>

The file can then be downloaded via the link https://api.telegram.org/file/bot/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.

Parameters
$file_id : string

File identifier to get information about

Tags
link
https://core.telegram.org/bots/api#getfile
Return values
PromiseInterface<string|int, File>

uploadStickerFile()

Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success.

public uploadStickerFile(int $user_id, InputFile $sticker, string $sticker_format) : PromiseInterface<string|int, File>
Parameters
$user_id : int

User identifier of sticker file owner

$sticker : InputFile

A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More information on Sending Files: https://core.telegram.org/bots/api#sending-files

$sticker_format : string

Format of the sticker, must be one of "static", "animated", "video"

Tags
link
https://core.telegram.org/bots/api#uploadstickerfile
Return values
PromiseInterface<string|int, File>
On this page

Search results