PHP Class Telegram, TelegramBotPHP

Afficher le fichier Open project: Eleirbag89/TelegramBotPHP Class Usage Examples

Méthodes publiques

Méthode Description
Callback_ChatID ( ) \return the String callback_query
Callback_Data ( ) \return the String callback_data
Callback_ID ( ) \return the String callback_query id
Callback_Message ( ) \return the Message
Callback_Query ( ) \return the String callback_query
ChatID ( ) \return the String users's chat_id
Date ( ) \return the String message's date
FirstName ( ) Get the first name of the user
LastName ( ) Get the last name of the user
Location ( ) Get the location in the message
Text ( ) \return the String users's text
UpdateCount ( ) Get the number of updates
UpdateID ( ) Get the update_id of the message
Username ( ) Get the username of the user
__construct ( $bot_id ) Create a Telegram instance from the bot token \param bot_id the bot token \return an instance of the class
answerCallbackQuery ( array $content ) Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Values inside $content:
Parameters Type Required Description
callback_query_id String Yes Unique identifier for the query to be answered
text String Optional Text of the notification. If not specified, nothing will be shown to the user
show_alert Boolean Optional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
\param $content the request parameters as array \return the JSON Telegram's reply
answerInlineQuery ( array $content ) Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.
Values inside $content:
Parameters Type Required Description
inline_query_id String Yes Unique identifier for the answered query
results Array of InlineQueryResult Yes A JSON-serialized array of results for the inline query
cache_time Integer Optional The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
is_personal Boolean Optional Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
next_offset String Optional Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
switch_pm_text String Optional If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
switch_pm_parameter String Optional Parameter for the start message sent to the bot when user presses the switch button

Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
\param $content the request parameters as array \return the JSON Telegram's reply
buildForceReply ( $selective = true ) * Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
buildInlineKeyBoard ( array $options ) This object represents an inline keyboard that appears right next to the message it belongs to.
buildInlineKeyboardButton ( $text, $url = "", $callback_data = "", $switch_inline_query = "" ) This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
buildKeyBoard ( array $options, $onetime = false, $resize = false, $selective = true ) This object represents a custom keyboard with reply options \param $options Array of Array of String; Array of button rows, each represented by an Array of Strings \param $onetime Boolean Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
buildKeyBoardHide ( $selective = true ) Upon receiving a message with this object, Telegram clients will hide the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button.
buildKeyboardButton ( $text, $request_contact = false, $request_location = false ) This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
downloadFile ( $telegram_file_path, $local_file_path ) Use this method to to download a file from the Telegram servers.
editMessageCaption ( array $content ) Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
caption String Optional New caption of the message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
editMessageReplyMarkup ( array $content ) Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
editMessageText ( array $content ) Use this method to edit text messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
text String Yes New text of the message
parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
disable_web_page_preview Boolean Optional Disables link previews for links in this message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
endpoint ( $api, array $content, $post = true ) Contacts the various API's endpoints \param api the API endpoint \param $content the request parameters as array \param $post boolean tells if $content needs to be sends \return the JSON Telegram's reply
forwardMessage ( array $content ) Use this method to forward messages of any kind. On success, the sent Message is returned
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
from_chat_id Integer Yes Unique identifier for the chat where the original message was sent — User or GroupChat id
message_id Integer Yes Unique message identifier
\param $content the request parameters as array \return the JSON Telegram's reply
getChat ( array $content ) 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.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
getChatAdministrators ( array $content ) Use this method to get a list of administrators in a chat. 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.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
getChatMember ( array $content ) Use this method to get information about a member of a chat. Returns a ChatMember object on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply
getChatMembersCount ( array $content ) Use this method to get the number of members in a chat. Returns Int on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
getData ( ) Get the POST request of a user in a Webhook or the message actually processed in a getUpdates() enviroment.
getFile ( $file_id ) Use this method to get basic info 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. 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.
getMe ( ) A simple method for testing your bot's auth token. Requires no parameters.
getUpdates ( $offset, $limit = 100, $timeout, $update = true ) Use this method to receive incoming updates using long polling.
getUserProfilePhotos ( array $content ) Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Values inside $content:
Parameters Type Required Description
user_id Integer Yes Unique identifier of the target user
offset Integer Optional Sequential number of the first photo to be returned. By default, all photos are returned.
limit Integer Optional Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
\param $content the request parameters as array \return the JSON Telegram's reply
kickChatMember ( array $content ) Use this method to kick a user from a group or a supergroup. 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. Returns True on success.
Note: This will method only work if the ‘All Members Are Admins’ setting is off in the target group. Otherwise members may only be removed by the group's creator or by the member that added them.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply
leaveChat ( array $content ) Use this method for your bot to leave a group, supergroup or channel. Returns True on success.


Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
messageFromGroup ( ) \return BOOLEAN true if the message is from a Group chat, false otherwise
messageFromGroupTitle ( )
sendAudio ( array $content ) Use this method to send audio files, if you want Telegram clients to display them in the music player. 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.
sendChatAction ( array $content ) Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
sendContact ( array $content ) Use this method to send phone contacts. On success, the sent Message is returned.


Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
phone_number String Yes Contact's phone number
first_name String Yes Contact's first name
last_name String Optional Contact's last name
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendDocument ( array $content ) Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
document InputFile or String Yes File to send. You can either pass a file_id as String to resend a file that is already on the Telegram servers, or upload a new file using multipart/form-data.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendLocation ( array $content ) Use this method to send point on the map. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
latitude Float number Yes Latitude of location
longitude Float number Yes Longitude of location
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendMessage ( array $content ) Contacts the various API's endpoints
Values inside $content:
*
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
text String Yes Text of the message to be sent
parse_mode String Optional Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message. For the moment, only Telegram for Android supports this.
disable_web_page_preview Boolean Optional Disables link previews for links in this message
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendPhoto ( array $content ) Use this method to send photos. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
photo InputFile or String Yes Photo to send. You can either pass a file_id as String to resend a photo that is already on the Telegram servers, or upload a new photo using multipart/form-data.
caption String Optional Photo caption (may also be used when resending photos by file_id).
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or >ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendSticker ( array $content ) Use this method to send .webp stickers. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
sticker InputFile or String Yes Sticker to send. You can either pass a file_id as String to resend a sticker that is already on the Telegram servers, or upload a new sticker using multipart/form-data.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendVenue ( array $content ) Use this method to send information about a venue. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
latitude Float number Yes Latitude of the venue
longitude Float number Yes Longitude of the venue
title String Yes Name of the venue
address String Yes Address of the venue
foursquare_id String Optional Foursquare identifier of the venue
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide reply keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendVideo ( array $content ) Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
video InputFile or String Yes Video to send. You can either pass a file_id as String to resend a video that is already on the Telegram servers, or upload a new video file using multipart/form-data.
duration Integer Optional Duration of sent video in seconds
caption String Optional Video caption (may also be used when resending videos by file_id).
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
sendVoice ( array $content ) Use this method to send audio files, if you want Telegram clients to 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). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
voice InputFile or String Yes Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
duration Integer Optional Duration of sent audio in seconds
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
serveUpdate ( $update ) Use this method to use the bultin function like Text() or Username() on a specific update.
setData ( array $data ) Set the data currently used
setWebhook ( $url, $certificate = "" ) 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, we will give up after a reasonable amount of attempts.
unbanChatMember ( array $content ) Use this method to unban a previously kicked user in a supergroup. 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. Returns True on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply

Private Methods

Méthode Description
sendAPIRequest ( $url, array $content, $post = true )

Method Details

Callback_ChatID() public méthode

\return the String callback_query
public Callback_ChatID ( )

Callback_Data() public méthode

\return the String callback_data
public Callback_Data ( )

Callback_ID() public méthode

\return the String callback_query id
public Callback_ID ( )

Callback_Message() public méthode

\return the Message
public Callback_Message ( )

Callback_Query() public méthode

\return the String callback_query
public Callback_Query ( )

ChatID() public méthode

\return the String users's chat_id
public ChatID ( )

Date() public méthode

\return the String message's date
public Date ( )

FirstName() public méthode

Get the first name of the user
public FirstName ( )

LastName() public méthode

Get the last name of the user
public LastName ( )

Location() public méthode

Get the location in the message
public Location ( )

Text() public méthode

\return the String users's text
public Text ( )

UpdateCount() public méthode

Get the number of updates
public UpdateCount ( )

UpdateID() public méthode

Get the update_id of the message
public UpdateID ( )

Username() public méthode

Get the username of the user
public Username ( )

__construct() public méthode

Create a Telegram instance from the bot token \param bot_id the bot token \return an instance of the class
public __construct ( $bot_id )

answerCallbackQuery() public méthode

Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Values inside $content:
Parameters Type Required Description
callback_query_id String Yes Unique identifier for the query to be answered
text String Optional Text of the notification. If not specified, nothing will be shown to the user
show_alert Boolean Optional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
\param $content the request parameters as array \return the JSON Telegram's reply
public answerCallbackQuery ( array $content )
$content array

answerInlineQuery() public méthode

Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.
Values inside $content:
Parameters Type Required Description
inline_query_id String Yes Unique identifier for the answered query
results Array of InlineQueryResult Yes A JSON-serialized array of results for the inline query
cache_time Integer Optional The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
is_personal Boolean Optional Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
next_offset String Optional Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
switch_pm_text String Optional If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
switch_pm_parameter String Optional Parameter for the start message sent to the bot when user presses the switch button

Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
\param $content the request parameters as array \return the JSON Telegram's reply
public answerInlineQuery ( array $content )
$content array

buildForceReply() public méthode

\param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. \return the requested force reply as Array
public buildForceReply ( $selective = true )

buildInlineKeyBoard() public méthode

\param $options Array of Array of InlineKeyboardButton; Array of button rows, each represented by an Array of InlineKeyboardButton \return the requested keyboard as Json
public buildInlineKeyBoard ( array $options )
$options array

buildInlineKeyboardButton() public méthode

\param $text String; Array of button rows, each represented by an Array of Strings \param $url String Optional. HTTP url to be opened when button is pressed \param $callback_data String Optional. Data to be sent in a callback query to the bot when button is pressed \param $switch_inline_query String Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted. \return the requested button as Array
public buildInlineKeyboardButton ( $text, $url = "", $callback_data = "", $switch_inline_query = "" )

buildKeyBoard() public méthode

\param $resize Boolean Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. \param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. \return the requested keyboard as Json
public buildKeyBoard ( array $options, $onetime = false, $resize = false, $selective = true )
$options array

buildKeyBoardHide() public méthode

\param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. \return the requested keyboard hide as Array
public buildKeyBoardHide ( $selective = true )

buildKeyboardButton() public méthode

\param $text String; Array of button rows, each represented by an Array of Strings \param $request_contact Boolean Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only \param $request_location Boolean Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only \return the requested button as Array
public buildKeyboardButton ( $text, $request_contact = false, $request_location = false )

downloadFile() public méthode

\param $telegram_file_path String File path on Telegram servers \param $local_file_path String File path where save the file
public downloadFile ( $telegram_file_path, $local_file_path )

editMessageCaption() public méthode

Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
caption String Optional New caption of the message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
public editMessageCaption ( array $content )
$content array

editMessageReplyMarkup() public méthode

Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
public editMessageReplyMarkup ( array $content )
$content array

editMessageText() public méthode

Use this method to edit text messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String No Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_id Integer No Required if inline_message_id is not specified. Unique identifier of the sent message
inline_message_id String No Required if chat_id and message_id are not specified. Identifier of the inline message
text String Yes New text of the message
parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
disable_web_page_preview Boolean Optional Disables link previews for links in this message
reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for an inline keyboard.
\param $content the request parameters as array \return the JSON Telegram's reply
public editMessageText ( array $content )
$content array

endpoint() public méthode

Contacts the various API's endpoints \param api the API endpoint \param $content the request parameters as array \param $post boolean tells if $content needs to be sends \return the JSON Telegram's reply
public endpoint ( $api, array $content, $post = true )
$content array

forwardMessage() public méthode

Use this method to forward messages of any kind. On success, the sent Message is returned
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
from_chat_id Integer Yes Unique identifier for the chat where the original message was sent — User or GroupChat id
message_id Integer Yes Unique message identifier
\param $content the request parameters as array \return the JSON Telegram's reply
public forwardMessage ( array $content )
$content array

getChat() public 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.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
public getChat ( array $content )
$content array

getChatAdministrators() public méthode

Use this method to get a list of administrators in a chat. 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.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
public getChatAdministrators ( array $content )
$content array

getChatMember() public méthode

Use this method to get information about a member of a chat. Returns a ChatMember object on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply
public getChatMember ( array $content )
$content array

getChatMembersCount() public méthode

Use this method to get the number of members in a chat. Returns Int on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
public getChatMembersCount ( array $content )
$content array

getData() public méthode

\return the JSON users's message
public getData ( )

getFile() public méthode

\param $file_id String File identifier to get info about \return the JSON Telegram's reply
public getFile ( $file_id )

getMe() public méthode

Returns basic information about the bot in form of a User object. \return the JSON Telegram's reply
public getMe ( )

getUpdates() public méthode

\param $offset Integer 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. \param $limit Integer Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100 \param $timeout Integer Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling \param $update Boolean If true updates the pending message list to the last update received. Default to true. \return the updates as Array
public getUpdates ( $offset, $limit = 100, $timeout, $update = true )

getUserProfilePhotos() public méthode

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Values inside $content:
Parameters Type Required Description
user_id Integer Yes Unique identifier of the target user
offset Integer Optional Sequential number of the first photo to be returned. By default, all photos are returned.
limit Integer Optional Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
\param $content the request parameters as array \return the JSON Telegram's reply
public getUserProfilePhotos ( array $content )
$content array

kickChatMember() public méthode

Use this method to kick a user from a group or a supergroup. 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. Returns True on success.
Note: This will method only work if the ‘All Members Are Admins’ setting is off in the target group. Otherwise members may only be removed by the group's creator or by the member that added them.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply
public kickChatMember ( array $content )
$content array

leaveChat() public méthode

Use this method for your bot to leave a group, supergroup or channel. Returns True on success.


Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
\param $content the request parameters as array \return the JSON Telegram's reply
public leaveChat ( array $content )
$content array

messageFromGroup() public méthode

\return BOOLEAN true if the message is from a Group chat, false otherwise
public messageFromGroup ( )

messageFromGroupTitle() public méthode

sendAudio() public méthode

For backward compatibility, when the fields title and performer are both empty and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. For this to work, the audio must be in an .ogg file encoded with OPUS. This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
audio InputFile or String Yes Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
duration Integer Optional Duration of the audio in seconds
performer String Optional Performer
title String Optional Track name
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendAudio ( array $content )
$content array

sendChatAction() public méthode

Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
action String Yes Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendChatAction ( array $content )
$content array

sendContact() public méthode

Use this method to send phone contacts. On success, the sent Message is returned.


Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
phone_number String Yes Contact's phone number
first_name String Yes Contact's first name
last_name String Optional Contact's last name
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendContact ( array $content )
$content array

sendDocument() public méthode

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
document InputFile or String Yes File to send. You can either pass a file_id as String to resend a file that is already on the Telegram servers, or upload a new file using multipart/form-data.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendDocument ( array $content )
$content array

sendLocation() public méthode

Use this method to send point on the map. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
latitude Float number Yes Latitude of location
longitude Float number Yes Longitude of location
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendLocation ( array $content )
$content array

sendMessage() public méthode

Contacts the various API's endpoints
Values inside $content:
*
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
text String Yes Text of the message to be sent
parse_mode String Optional Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message. For the moment, only Telegram for Android supports this.
disable_web_page_preview Boolean Optional Disables link previews for links in this message
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendMessage ( array $content )
$content array

sendPhoto() public méthode

Use this method to send photos. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
photo InputFile or String Yes Photo to send. You can either pass a file_id as String to resend a photo that is already on the Telegram servers, or upload a new photo using multipart/form-data.
caption String Optional Photo caption (may also be used when resending photos by file_id).
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or >ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendPhoto ( array $content )
$content array

sendSticker() public méthode

Use this method to send .webp stickers. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
sticker InputFile or String Yes Sticker to send. You can either pass a file_id as String to resend a sticker that is already on the Telegram servers, or upload a new sticker using multipart/form-data.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendSticker ( array $content )
$content array

sendVenue() public méthode

Use this method to send information about a venue. On success, the sent Message is returned.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
latitude Float number Yes Latitude of the venue
longitude Float number Yes Longitude of the venue
title String Yes Name of the venue
address String Yes Address of the venue
foursquare_id String Optional Foursquare identifier of the venue
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide reply keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendVenue ( array $content )
$content array

sendVideo() public méthode

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
video InputFile or String Yes Video to send. You can either pass a file_id as String to resend a video that is already on the Telegram servers, or upload a new video file using multipart/form-data.
duration Integer Optional Duration of sent video in seconds
caption String Optional Video caption (may also be used when resending videos by file_id).
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendVideo ( array $content )
$content array

sendVoice() public méthode

Use this method to send audio files, if you want Telegram clients to 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). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Values inside $content:
Parameters Type Required Description
chat_id Integer Yes Unique identifier for the message recipient — User or GroupChat id
voice InputFile or String Yes Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
duration Integer Optional Duration of sent audio in seconds
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
reply_markup ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply Optional Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
\param $content the request parameters as array \return the JSON Telegram's reply
public sendVoice ( array $content )
$content array

serveUpdate() public méthode

\param $update Integer The index of the update in the updates array.
public serveUpdate ( $update )

setData() public méthode

Set the data currently used
public setData ( array $data )
$data array

setWebhook() public méthode

If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. \param $url String HTTPS url to send updates to. Use an empty string to remove webhook integration \param $certificate InputFile Upload your public key certificate so that the root certificate in use can be checked \return the JSON Telegram's reply
public setWebhook ( $url, $certificate = "" )

unbanChatMember() public méthode

Use this method to unban a previously kicked user in a supergroup. 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. Returns True on success.
Values inside $content:
Parameters Type Required Description
chat_id Integer or String Yes Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
user_id Integer Yes Unique identifier of the target user
\param $content the request parameters as array \return the JSON Telegram's reply
public unbanChatMember ( array $content )
$content array