PHP Class Longman\TelegramBot\Request

Afficher le fichier Open project: akalongman/php-telegram-bot Class Usage Examples

Méthodes publiques

Méthode Description
answerCallbackQuery ( array $data ) : ServerResponse Use this method to send answers to callback queries sent from inline keyboards. On success, True is returned.
answerInlineQuery ( array $data ) : ServerResponse Use this method to send answers to an inline query. On success, True is returned.
downloadFile ( Longman\TelegramBot\Entities\File $file ) : boolean Download file
editMessageCaption ( array $data ) : ServerResponse Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
editMessageReplyMarkup ( array $data ) : ServerResponse Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
editMessageText ( array $data ) : ServerResponse Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
emptyResponse ( ) : ServerResponse Return an empty Server Response
execute ( string $action, array $data = [] ) : string Execute HTTP Request
forwardMessage ( array $data ) : ServerResponse Use this method to forward messages of any kind. On success, the sent Message is returned
generateGeneralFakeServerResponse ( array $data = [] ) : array Generate general fake server response
getChat ( array $data ) : ServerResponse Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
getChatAdministrators ( array $data ) : ServerResponse Use this method to get a list of administrators in a chat.
getChatMember ( array $data ) : ServerResponse Use this method to get information about a member of a chat. Returns a ChatMember object on success.
getChatMembersCount ( array $data ) : ServerResponse Use this method to get the number of members in a chat. Returns Int on success.
getFile ( array $data ) : ServerResponse Use this method to get basic info about a file and prepare it for downloading. On success, a File object is returned.
getInput ( ) : string Set input from custom input or stdin and return it
getMe ( ) : ServerResponse Returns basic information about the bot in form of a User object
getUpdates ( array $data ) : ServerResponse Get updates
getUserProfilePhotos ( array $data ) : ServerResponse Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
getWebhookInfo ( ) : ServerResponse Use this method to get current webhook status.
initialize ( Telegram $telegram ) Initialize
kickChatMember ( array $data ) : ServerResponse Use this method to kick a user from a group or a supergroup. Returns True on success.
leaveChat ( array $data ) : ServerResponse Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
send ( string $action, array $data = [] ) : ServerResponse Send command
sendAudio ( array $data, string $file = null ) : ServerResponse Use this method to send audio files
sendChatAction ( array $data ) : ServerResponse Use this method when you need to tell the user that something is happening on the bot's side.
sendContact ( array $data ) : ServerResponse Use this method to send phone contacts. On success, the sent Message is returned.
sendDocument ( array $data, string $file = null ) : ServerResponse Use this method to send general files. On success, the sent Message is returned.
sendLocation ( array $data ) : ServerResponse Use this method to send point on the map. On success, the sent Message is returned.
sendMessage ( array $data ) : ServerResponse Use this method to send text messages. On success, the sent Message is returned
sendPhoto ( array $data, string $file = null ) : ServerResponse Use this method to send photos. On success, the sent Message is returned
sendSticker ( array $data, string $file = null ) : ServerResponse Use this method to send .webp stickers. On success, the sent Message is returned.
sendToActiveChats ( string $callback_function, array $data, boolean $send_groups = true, boolean $send_super_groups = true, boolean $send_users = true, string $date_from = null, string $date_to = null ) : array Send message to all active chats
sendVenue ( array $data ) : ServerResponse Use this method to send information about a venue. On success, the sent Message is returned.
sendVideo ( array $data, string $file = null ) : ServerResponse Use this method to send video files. On success, the sent Message is returned.
sendVoice ( array $data, string $file = null ) : ServerResponse Use this method to send audio files. On success, the sent Message is returned.
setWebhook ( string $url = '', string $file = null ) : ServerResponse Set webhook
unbanChatMember ( array $data ) : ServerResponse Use this method to unban a previously kicked user in a supergroup. Returns True on success.

Méthodes protégées

Méthode Description
encodeFile ( string $file ) : resource Encode file

Private Methods

Méthode Description
assignEncodedFile ( array &$data, string $field, string $file ) Assign an encoded file to a data array
ensureNonEmptyData ( array $data ) Make sure the data isn't empty, else throw an exception
ensureValidAction ( string $action ) Make sure the action is valid, else throw an exception
setUpRequestParams ( array $data ) : array Properly set up the request params

Method Details

answerCallbackQuery() public static méthode

The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
public static answerCallbackQuery ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

answerInlineQuery() public static méthode

No more than 50 results per query are allowed.
public static answerInlineQuery ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

downloadFile() public static méthode

Download file
public static downloadFile ( Longman\TelegramBot\Entities\File $file ) : boolean
$file Longman\TelegramBot\Entities\File
Résultat boolean

editMessageCaption() public static méthode

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageCaption ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

editMessageReplyMarkup() public static méthode

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageReplyMarkup ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

editMessageText() public static méthode

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageText ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

emptyResponse() public static méthode

No request to telegram are sent, this function is used in commands that don't need to fire a message after execution
public static emptyResponse ( ) : ServerResponse
Résultat Longman\TelegramBot\Entities\ServerResponse

encodeFile() protected static méthode

Encode file
protected static encodeFile ( string $file ) : resource
$file string
Résultat resource

execute() public static méthode

Execute HTTP Request
public static execute ( string $action, array $data = [] ) : string
$action string Action to execute
$data array Data to attach to the execution
Résultat string Result of the HTTP Request

forwardMessage() public static méthode

Use this method to forward messages of any kind. On success, the sent Message is returned
public static forwardMessage ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

generateGeneralFakeServerResponse() public static méthode

Generate general fake server response
public static generateGeneralFakeServerResponse ( array $data = [] ) : array
$data array Data to add to fake response
Résultat array Fake response data

getChat() public static méthode

Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
public static getChat ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getChatAdministrators() public static méthode

On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
public static getChatAdministrators ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getChatMember() public static méthode

Use this method to get information about a member of a chat. Returns a ChatMember object on success.
public static getChatMember ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getChatMembersCount() public static méthode

Use this method to get the number of members in a chat. Returns Int on success.
public static getChatMembersCount ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getFile() public static méthode

For the moment, bots can download files of up to 20MB in size. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where 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.
public static getFile ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getInput() public static méthode

Set input from custom input or stdin and return it
public static getInput ( ) : string
Résultat string

getMe() public static méthode

Returns basic information about the bot in form of a User object
public static getMe ( ) : ServerResponse
Résultat Longman\TelegramBot\Entities\ServerResponse

getUpdates() public static méthode

Get updates
public static getUpdates ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getUserProfilePhotos() public static méthode

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
public static getUserProfilePhotos ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

getWebhookInfo() public static méthode

Use this method to get current webhook status.
public static getWebhookInfo ( ) : ServerResponse
Résultat Longman\TelegramBot\Entities\ServerResponse

initialize() public static méthode

Initialize
public static initialize ( Telegram $telegram )
$telegram Telegram

kickChatMember() public static méthode

In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work.
public static kickChatMember ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

leaveChat() public static méthode

Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
public static leaveChat ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

send() public static méthode

Send command
public static send ( string $action, array $data = [] ) : ServerResponse
$action string
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendAudio() public static méthode

Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead.
public static sendAudio ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

sendChatAction() public static méthode

The status is set for 5 seconds or less. (when a message arrives from your bot, Telegram clients clear its typing status)
public static sendChatAction ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendContact() public static méthode

Use this method to send phone contacts. On success, the sent Message is returned.
public static sendContact ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendDocument() public static méthode

Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
public static sendDocument ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

sendLocation() public static méthode

Use this method to send point on the map. On success, the sent Message is returned.
public static sendLocation ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendMessage() public static méthode

Use this method to send text messages. On success, the sent Message is returned
public static sendMessage ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendPhoto() public static méthode

Use this method to send photos. On success, the sent Message is returned
public static sendPhoto ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

sendSticker() public static méthode

Use this method to send .webp stickers. On success, the sent Message is returned.
public static sendSticker ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

sendToActiveChats() public static méthode

Send message to all active chats
public static sendToActiveChats ( string $callback_function, array $data, boolean $send_groups = true, boolean $send_super_groups = true, boolean $send_users = true, string $date_from = null, string $date_to = null ) : array
$callback_function string
$data array
$send_groups boolean
$send_super_groups boolean
$send_users boolean
$date_from string
$date_to string
Résultat array

sendVenue() public static méthode

Use this method to send information about a venue. On success, the sent Message is returned.
public static sendVenue ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse

sendVideo() public static méthode

Telegram clients support mp4 videos (other formats may be sent as Document). Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
public static sendVideo ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

sendVoice() public static méthode

Telegram clients will display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
public static sendVoice ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

setWebhook() public static méthode

Set webhook
public static setWebhook ( string $url = '', string $file = null ) : ServerResponse
$url string
$file string
Résultat Longman\TelegramBot\Entities\ServerResponse

unbanChatMember() public static méthode

The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work.
public static unbanChatMember ( array $data ) : ServerResponse
$data array
Résultat Longman\TelegramBot\Entities\ServerResponse