TelegramPHP Documentation

UpdateApi

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.

Receiving updates, by long polling or by webhook.

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

deleteWebhook()  : PromiseInterface<string|int, bool>
Use this method to remove webhook integration if you decide to switch back to getUpdates.
getUpdates()  : PromiseInterface<string|int, Collection<string|int, Update>>
Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
getWebhookInfo()  : PromiseInterface<string|int, WebhookInfo>
Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
setWebhook()  : PromiseInterface<string|int, bool>
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success.

Methods

deleteWebhook()

Use this method to remove webhook integration if you decide to switch back to getUpdates.

public deleteWebhook([bool|null $drop_pending_updates = null ]) : PromiseInterface<string|int, bool>

Returns True on success.

Parameters
$drop_pending_updates : bool|null = null

Optional. Pass True to drop all pending updates

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

getUpdates()

Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.

public getUpdates([int|null $offset = null ][, int|null $limit = null ][, int|null $timeout = null ][, array<int, string>|null $allowed_updates = null ]) : PromiseInterface<string|int, Collection<string|int, Update>>
Parameters
$offset : int|null = null

Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.

$limit : int|null = null

Optional. Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.

$timeout : int|null = null

Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.

$allowed_updates : array<int, string>|null = null

Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time.

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

setWebhook()

Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success.

public setWebhook(string $url[, InputFile|null $certificate = null ][, string|null $ip_address = null ][, int|null $max_connections = null ][, array<int, string>|null $allowed_updates = null ][, bool|null $drop_pending_updates = null ][, string|null $secret_token = null ]) : PromiseInterface<string|int, bool>

If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header "X-Telegram-Bot-Api-Secret-Token" with the secret token as content.

Parameters
$url : string

HTTPS URL to send updates to. Use an empty string to remove webhook integration.

$certificate : InputFile|null = null

Optional. Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.

$ip_address : string|null = null

Optional. The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS

$max_connections : int|null = null

Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.

$allowed_updates : array<int, string>|null = null

Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.

$drop_pending_updates : bool|null = null

Optional. Pass True to drop all pending updates

$secret_token : string|null = null

Optional. A secret token to be sent in a header "X-Telegram-Bot-Api-Secret-Token" in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

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

Search results