### Install via Composer Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Use Composer to add the library to your project directory. ```bash composer require eleirbag89/telegrambotphp ``` ```bash php composer.phar require eleirbag89/telegrambotphp ``` -------------------------------- ### getStickerSet Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get Sticker Set. ```APIDOC ## getStickerSet ### Description Get Sticker Set. ### Method POST ### Endpoint getStickerSet(array $content) ### Parameters #### Request Body - **content** (array) - Required - Sticker set parameters. ### Response Returns the API response. ``` -------------------------------- ### getFile Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Use this method to get basic info about a file and prepare it for downloading. ```APIDOC ## getFile ### Description Use this method to get basic info about a file and prepare it for downloading. ### Parameters - **$file_id** (string) - Required - The file identifier. ``` -------------------------------- ### getMyCommands Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the list of the bot commands. ```APIDOC ## getMyCommands ### Description Get the list of the bot commands. ### Parameters - **$content** (array) - Required - The parameters for getting bot commands. ``` -------------------------------- ### getChat Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get Chat Information. ```APIDOC ## getChat ### Description Get Chat Information. ### Parameters - **$content** (array) - Required - The parameters for getting chat information. ``` -------------------------------- ### Username Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the username of the user. ```APIDOC ## Username ### Description Get the username of the user. ### Method GET ### Endpoint Username() ### Parameters None ### Response Returns the username of the user. ``` -------------------------------- ### FirstName Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the first name of the user. ```APIDOC ## FirstName ### Description Get the first name of the user. ### Method GET ### Endpoint FirstName() ### Parameters None ### Response Returns the first name of the user. ``` -------------------------------- ### getFile($_file_id) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets basic info about a file and prepares it for downloading. Returns a File object and a download link valid for at least 1 hour. ```APIDOC ## getFile($_file_id) ### Description 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. ### Method `getFile` ### Parameters #### Parameters - **$_file_id** (String) - Required - File identifier to get info about ### Returns - **JSON** - The Telegram's reply. ``` -------------------------------- ### getChatAdministrators Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get chat Administrators. ```APIDOC ## getChatAdministrators ### Description Get chat Administrators. ### Parameters - **$content** (array) - Required - The parameters for getting chat administrators. ``` -------------------------------- ### getChatMenuButton Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the chat menu button. ```APIDOC ## getChatMenuButton ### Description Get the chat menu button. ### Parameters - **$content** (array) - Required - The parameters for getting the chat menu button. ``` -------------------------------- ### LastName Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the last name of the user. ```APIDOC ## LastName ### Description Get the last name of the user. ### Method GET ### Endpoint LastName() ### Parameters None ### Response Returns the last name of the user. ``` -------------------------------- ### getMyDefaultAdministratorRights Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the default aministrator rights. ```APIDOC ## getMyDefaultAdministratorRights ### Description Get the default aministrator rights. ### Parameters - **$content** (array) - Required - The parameters for getting default administrator rights. ``` -------------------------------- ### Location Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the location in the message. ```APIDOC ## Location ### Description Get the location in the message. ### Method GET ### Endpoint Location() ### Parameters None ### Response Returns the location object. ``` -------------------------------- ### Date Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the date of the current message. ```APIDOC ## Date ### Description Get the date of the current message. ### Method GET ### Endpoint Date() ### Parameters None ### Response Returns the date of the message. ``` -------------------------------- ### Callback_Query Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the callback_query of the current update. ```APIDOC ## Callback_Query ### Description Get the callback_query of the current update. ### Method GET ### Endpoint Callback_Query() ### Parameters None ### Response Returns the callback_query object. ``` -------------------------------- ### Callback_Data Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the data of the current callback. ```APIDOC ## Callback_Data ### Description Get the data of the current callback. ### Method GET ### Endpoint Callback_Data() ### Parameters None ### Response Returns the callback data. ``` -------------------------------- ### getData Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the data of the current message. ```APIDOC ## getData ### Description Get the data of the current message. ``` -------------------------------- ### Text() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets the text of the current message. Returns the user's text as a string. ```APIDOC ## Text() ### Description Get the text of the current message. ### Method Text ### Parameters None. ### Returns The String users's text. ``` -------------------------------- ### Caption Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the caption of the current message. ```APIDOC ## Caption ### Description Get the caption of the current message. ``` -------------------------------- ### Text Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the text of the current message. ```APIDOC ## Text ### Description Get the text of the current message. ``` -------------------------------- ### Callback_Data() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets the data of the current callback. Deprecated: Use Text() instead. ```APIDOC ## Callback_Data() ### Description Get the data of the current callback. **Deprecated:** Use Text() instead. ### Method Callback_Data ### Returns - the String callback_data. ``` -------------------------------- ### getUpdateType Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the update type. ```APIDOC ## getUpdateType ### Description Get the update type. ### Method GET ### Endpoint getUpdateType() ### Parameters None ### Response Returns the update type. ``` -------------------------------- ### Build an InlineKeyboard Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Demonstrates how to create an InlineKeyboard with buttons linked to URLs and send it via sendMessage. ```php $option = array( //First row array($telegram->buildInlineKeyBoardButton("Button 1", $url="http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url="http://link2.com")), //Second row array($telegram->buildInlineKeyBoardButton("Button 3", $url="http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url="http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url="http://link5.com")), //Third row array($telegram->buildInlineKeyBoardButton("Button 6", $url="http://link6.com")) ); $keyb = $telegram->buildInlineKeyBoard($option); $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "This is a Keyboard Test"); $telegram->sendMessage($content); ``` -------------------------------- ### Build a ReplyKeyboard Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Demonstrates how to arrange buttons in rows and columns for a ReplyKeyboard and send it via sendMessage. ```php $option = array( //First row array($telegram->buildKeyboardButton("Button 1"), $telegram->buildKeyboardButton("Button 2")), //Second row array($telegram->buildKeyboardButton("Button 3"), $telegram->buildKeyboardButton("Button 4"), $telegram->buildKeyboardButton("Button 5")), //Third row array($telegram->buildKeyboardButton("Button 6")) ); $keyb = $telegram->buildKeyBoard($option, $onetime=false); $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "This is a Keyboard Test"); $telegram->sendMessage($content); ``` -------------------------------- ### UpdateCount Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the number of updates. ```APIDOC ## UpdateCount ### Description Get the number of updates. ### Method GET ### Endpoint UpdateCount() ### Parameters None ### Response Returns the number of updates. ``` -------------------------------- ### getUserProfilePhotos Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get a list of profile pictures for a user. ```APIDOC ## getUserProfilePhotos ### Description Get a list of profile pictures for a user. ### Parameters - **$content** (array) - Required - The parameters for getting user profile photos. ``` -------------------------------- ### Chat Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the chat information of the current message. ```APIDOC ## Chat ### Description Get the chat information of the current message. ``` -------------------------------- ### UpdateID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the update_id of the message. ```APIDOC ## UpdateID ### Description Get the update_id of the message. ### Method GET ### Endpoint UpdateID() ### Parameters None ### Response Returns the update_id. ``` -------------------------------- ### buildInlineKeyboardButton($text, $url = '', $callback_data = '', $switch_inline_query = null, $switch_inline_query_current_chat = null, $callback_game = '', $pay = '') Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Creates an InlineKeyboardButton. Accepts text and optional fields for URL, callback data, inline query switches, game, and pay. Returns the button as an array. ```APIDOC ## buildInlineKeyboardButton($text, $url = '', $callback_data = '', $switch_inline_query = null, $switch_inline_query_current_chat = null, $callback_game = '', $pay = '') ### Description Create an InlineKeyboardButton. This object represents one button of an inline keyboard. You must use exactly one of the optional fields. ### Method buildInlineKeyboardButton ### Parameters - **$text** (String) - Required - Array of button rows, each represented by an Array of Strings. - **$url** (String) - Optional - HTTP url to be opened when button is pressed. - **$callback_data** (String) - Optional - Data to be sent in a callback query to the bot when button is pressed. - **$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. - **$switch_inline_query_current_chat** (String) - Optional - If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot's username will be inserted. - **$callback_game** (String) - Optional - Description of the game that will be launched when the user presses the button. - **$pay** (Boolean) - Optional - Specify True, to send a Pay button. ### Returns The requested button as Array. ``` -------------------------------- ### buildKeyBoard Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set a custom keyboard. ```APIDOC ## buildKeyBoard ### Description Set a custom keyboard. ### Method POST ### Endpoint buildKeyBoard(array $options, $onetime=false, $resize=false, $selective=true) ### Parameters #### Request Body - **options** (array) - Required - Keyboard options. - **onetime** (bool) - Optional - Whether the keyboard is one-time. - **resize** (bool) - Optional - Whether to resize the keyboard. - **selective** (bool) - Optional - Whether to show the keyboard only to specific users. ### Response Returns the keyboard markup. ``` -------------------------------- ### buildKeyBoard() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Sets a custom keyboard with reply options. Accepts an array of button rows and optional parameters for one-time, resize, and selective display. ```APIDOC ## buildKeyBoard() ### Description Set a custom keyboard. This object represents a custom keyboard with reply options. ### Method buildKeyBoard ### Parameters - **$options** (array) - Required - Array of Array of String; Array of button rows, each represented by an Array of Strings. - **$onetime** (boolean) - Optional - Requests clients to hide the keyboard as soon as it's been used. Defaults to false. - **$resize** (boolean) - Optional - Requests clients to resize the keyboard vertically for optimal fit. Defaults to false. - **$selective** (boolean) - Optional - Use this parameter if you want to show the keyboard to specific users only. Defaults to true. ### Returns - The requested keyboard as Json. ``` -------------------------------- ### Inline_Query() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the inline_query of the current update. Returns the array inline_query. ```APIDOC ## Inline_Query() ### Description Get the inline_query of the current update. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters None ### Returns - **array** - The Array inline_query. ``` -------------------------------- ### buildInlineKeyBoard Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set an InlineKeyBoard. ```APIDOC ## buildInlineKeyBoard ### Description Set an InlineKeyBoard. ### Method POST ### Endpoint buildInlineKeyBoard(array $options) ### Parameters #### Request Body - **options** (array) - Required - Inline keyboard options. ### Response Returns the inline keyboard markup. ``` -------------------------------- ### messageFromGroupTitle() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the title of the group chat. Returns a string of the title chat. ```APIDOC ## messageFromGroupTitle() ### Description Get the title of the group chat. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters None ### Returns - **string** - A String of the title chat. ``` -------------------------------- ### buildKeyboardButton Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Create a KeyboardButton. ```APIDOC ## buildKeyboardButton ### Description Create a KeyboardButton. ### Method POST ### Endpoint buildKeyboardButton($text, $request_contact=false, $request_location=false) ### Parameters #### Request Body - **text** (string) - Required - Button text. - **request_contact** (bool) - Optional - Request user's contact. - **request_location** (bool) - Optional - Request user's location. ### Response Returns the keyboard button. ``` -------------------------------- ### Callback_FromID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets the from_id of the current callback. ```APIDOC ## Callback_FromID() ### Description Get the from_id of the current callback. ### Method Callback_FromID ### Returns - the String callback_query from_id. ``` -------------------------------- ### Download a File Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Retrieve file information and download it to the local server. ```php $file = $telegram->getFile($file_id); $telegram->downloadFile($file['result']['file_path'], './my_downloaded_file_on_local_server.png'); ``` -------------------------------- ### messageFromGroupTitle Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the title of the group chat. ```APIDOC ## messageFromGroupTitle ### Description Get the title of the group chat. ### Method GET ### Endpoint messageFromGroupTitle() ### Parameters None ### Response Returns the title of the group chat. ``` -------------------------------- ### ReplyToMessageFromUserID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the reply_to_message forward_from user_id of the current message. Returns the String reply_to_message forward_from user_id. ```APIDOC ## ReplyToMessageFromUserID() ### Description Get the reply_to_message forward_from user_id of the current message. ### Method ReplyToMessageFromUserID ### Parameters None ### Returns - **String** - The reply_to_message forward_from user_id. ``` -------------------------------- ### getUserProfilePhotos(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get a list of profile pictures for a user. Accepts an array of request parameters and returns the JSON Telegram reply. ```APIDOC ## getUserProfilePhotos(array $content) ### Description Get a list of profile pictures for a user. See getUserProfilePhotos for the input values. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns - **mixed** - The JSON Telegram's reply. ``` -------------------------------- ### getContactPhoneNumber Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the contact phone number. ```APIDOC ## getContactPhoneNumber ### Description Get the contact phone number. ### Method GET ### Endpoint getContactPhoneNumber() ### Parameters None ### Response Returns the contact phone number. ``` -------------------------------- ### __construct($bot_token, $log_errors = true, $proxy = []) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Class constructor. Creates a Telegram instance from the bot token. ```APIDOC ## __construct($bot_token, $log_errors = true, $proxy = []) ### Description Class constructor. Creates a Telegram instance from the bot token. ### Method Constructor ### Parameters - **$bot_token** (string) - Required - The bot token. - **$log_errors** (bool) - Optional - Enable or disable the logging. Default: true. - **$proxy** (array) - Optional - Array with the proxy configuration (url, port, type, auth). Default: []. ### Returns An instance of the class. ``` -------------------------------- ### buildInlineKeyboardButton Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Create an InlineKeyboardButton. ```APIDOC ## buildInlineKeyboardButton ### Description Create an InlineKeyboardButton. ### Method POST ### Endpoint buildInlineKeyboardButton($text, $url='', $callback_data='', $switch_inline_query=null, $switch_inline_query_current_chat=null, $callback_game='', $pay='') ### Parameters #### Request Body - **text** (string) - Required - Button text. - **url** (string) - Optional - URL to open when button is pressed. - **callback_data** (string) - Optional - Data to be sent in a callback query. - **switch_inline_query** (string) - Optional - Inline query to switch to. - **switch_inline_query_current_chat** (string) - Optional - Inline query to switch to in the current chat. - **callback_game** (string) - Optional - Description of the game to start. - **pay** (string) - Optional - Specify True to send a Pay button. ### Response Returns the inline keyboard button. ``` -------------------------------- ### Clone via Git Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Download the library source code directly from the repository using Git. ```bash git clone https://github.com/Eleirbag89/TelegramBotPHP.git ``` -------------------------------- ### buildInlineKeyBoard(array $options) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Sets an inline keyboard that appears next to the message. Accepts an array of button rows and returns the keyboard as JSON. ```APIDOC ## buildInlineKeyBoard(array $options) ### Description Set an InlineKeyBoard. This object represents an inline keyboard that appears right next to the message it belongs to. ### Method buildInlineKeyBoard ### Parameters - **$options** (array) - Required - Array of Array of InlineKeyboardButton; Array of button rows, each represented by an Array of InlineKeyboardButton. ### Returns The requested keyboard as Json. ``` -------------------------------- ### Callback_FromID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the from_id of the current callback. ```APIDOC ## Callback_FromID ### Description Get the from_id of the current callback. ### Method GET ### Endpoint Callback_FromID() ### Parameters None ### Response Returns the from_id. ``` -------------------------------- ### Include via Composer Autoloader Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Include the Composer autoloader and initialize the Telegram class with your bot token. ```php include (__DIR__ . '/vendor/autoload.php'); $telegram = new Telegram('YOUR TELEGRAM TOKEN HERE'); ``` -------------------------------- ### buildForceReply Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Display a reply interface to the user. ```APIDOC ## buildForceReply ### Description Display a reply interface to the user. ### Method POST ### Endpoint buildForceReply($selective=true) ### Parameters #### Request Body - **selective** (bool) - Optional - Whether to show the reply interface only to specific users. ### Response Returns the force reply markup. ``` -------------------------------- ### Callback_ChatID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the chat_id of the current callback. ```APIDOC ## Callback_ChatID ### Description Get the chat_id of the current callback. ### Method GET ### Endpoint Callback_ChatID() ### Parameters None ### Response Returns the chat_id. ``` -------------------------------- ### Callback_Message Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the message of the current callback. ```APIDOC ## Callback_Message ### Description Get the message of the current callback. ### Method GET ### Endpoint Callback_Message() ### Parameters None ### Response Returns the message object. ``` -------------------------------- ### getMe Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html A method for testing your bot. Returns basic information about the bot. ```APIDOC ## getMe ### Description A method for testing your bot. Returns basic information about the bot. ``` -------------------------------- ### getMe() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html A method for testing your bot. Returns basic information about the bot. ```APIDOC ## getMe() ### Description A method for testing your bot. See getMe. ### Method `getMe` ### Parameters None ### Returns - **JSON** - The Telegram's reply. ``` -------------------------------- ### downloadFile Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Use this method to download a file. ```APIDOC ## downloadFile ### Description Use this method to download a file. ### Parameters - **$telegram_file_path** (string) - Required - The file path on Telegram. - **$local_file_path** (string) - Required - The local file path to save to. ``` -------------------------------- ### Inline_Query Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the inline_query of the current update. ```APIDOC ## Inline_Query ### Description Get the inline_query of the current update. ### Method GET ### Endpoint Inline_Query() ### Parameters None ### Response Returns the inline_query object. ``` -------------------------------- ### MessageID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the message_id of the current message. ```APIDOC ## MessageID ### Description Get the message_id of the current message. ``` -------------------------------- ### ChatID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the chat_id of the current message. ```APIDOC ## ChatID ### Description Get the chat_id of the current message. ``` -------------------------------- ### buildKeyboardButton() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Creates a KeyboardButton object. Accepts text and optional request_contact and request_location flags. ```APIDOC ## buildKeyboardButton() ### Description Create a KeyboardButton. This object represents one button of an inline keyboard. You must use exactly one of the optional fields. ### Method buildKeyboardButton ### Parameters - **$text** (string) - Required - Array of button rows, each represented by an Array of Strings. - **$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. Defaults to false. - **$request_location** (boolean) - Optional - If True, the user's current location will be sent when the button is pressed. Available in private chats only. Defaults to false. ### Returns - The requested button as Array. ``` -------------------------------- ### buildKeyBoardHide Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Hide a custom keyboard. ```APIDOC ## buildKeyBoardHide ### Description Hide a custom keyboard. ### Method POST ### Endpoint buildKeyBoardHide($selective=true) ### Parameters #### Request Body - **selective** (bool) - Optional - Whether to hide only for specific users. ### Response Returns the keyboard hide markup. ``` -------------------------------- ### __construct Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Class constructor for initializing the TelegramBotPHP instance with a bot token and optional error logging and proxy settings. ```APIDOC ## __construct ### Description Class constructor for initializing the TelegramBotPHP instance. ### Parameters - **$bot_token** (string) - Required - The bot token provided by BotFather. - **$log_errors** (bool) - Optional - Whether to log errors. Default is true. - **$proxy** (array) - Optional - Proxy settings as an array. ``` -------------------------------- ### Handle Updates with getUpdates Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Use the getUpdates method and iterate through updates, calling serveUpdate before accessing message values. ```php $telegram = new Telegram('YOUR TELEGRAM TOKEN HERE'); $req = $telegram->getUpdates(); for ($i = 0; $i < $telegram-> UpdateCount(); $i++) { // You NEED to call serveUpdate before accessing the values of message in Telegram Class $telegram->serveUpdate($i); $text = $telegram->Text(); $chat_id = $telegram->ChatID(); if ($text == '/start') { $reply = 'Working'; $content = array('chat_id' => $chat_id, 'text' => $reply); $telegram->sendMessage($content); } // DO OTHER STUFF } ``` -------------------------------- ### setMyCommands Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set the list of the bot commands. ```APIDOC ## setMyCommands ### Description Set the list of the bot commands. ### Parameters - **$content** (array) - Required - The parameters for setting bot commands. ``` -------------------------------- ### downloadFile($telegram_file_path, $local_file_path) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Downloads a file from the Telegram servers to a local file path. Takes the Telegram file path and the local file path as parameters. ```APIDOC ## downloadFile($telegram_file_path, $local_file_path) ### Description Use this method to download a file from the Telegram servers. ### Method downloadFile ### Parameters - $telegram_file_path (String) - Required - File path on Telegram servers - $local_file_path (String) - Required - File path where to save the file ### Returns Returns the JSON Telegram's reply. ``` -------------------------------- ### sendVideoNote Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send a video note. ```APIDOC ## sendVideoNote ### Description Send a video note. ### Method POST ### Endpoint sendVideoNote(array $content) ### Parameters #### Request Body - **content** (array) - Required - Video note content. ### Response Returns the API response. ``` -------------------------------- ### getGameHighScores Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get Game Hi Scores. ```APIDOC ## getGameHighScores ### Description Get Game Hi Scores. ### Parameters - **$content** (array) - Required - The parameters for getting game high scores. ``` -------------------------------- ### buildKeyBoardHide($selective = true) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Hides the current custom keyboard and displays the default letter-keyboard. Optionally shows the keyboard to specific users only. ```APIDOC ## buildKeyBoardHide($selective = true) ### Description Hide a custom keyboard. 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. ### Method buildKeyBoardHide ### Parameters - **$selective** (Boolean) - Optional - 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. ### Returns - the requested keyboard hide as Array. ``` -------------------------------- ### getChatMember Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get chat member information. ```APIDOC ## getChatMember ### Description Get chat member information. ### Parameters - **$content** (array) - Required - The parameters for getting chat member information. ``` -------------------------------- ### Upload a Photo Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Use curl_file_create to load a local file and send it as a photo. ```php // Load a local file to upload. If is already on Telegram's Servers just pass the resource id $img = curl_file_create('test.png','image/png'); $content = array('chat_id' => $chat_id, 'photo' => $img ); $telegram->sendPhoto($content); ``` -------------------------------- ### getChatMemberCount Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get chat member count. ```APIDOC ## getChatMemberCount ### Description Get chat member count. ### Parameters - **$content** (array) - Required - The parameters for getting chat member count. ``` -------------------------------- ### setWebhook Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set a WebHook for the bot. ```APIDOC ## setWebhook ### Description Set a WebHook for the bot. ### Parameters - **$url** (string) - Required - The webhook URL. - **$certificate** (string) - Optional - The certificate path. ``` -------------------------------- ### Callback_ID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets the callback_query id of the current update. ```APIDOC ## Callback_ID() ### Description Get the callback_query id of the current update. ### Method Callback_ID ### Returns - the String callback_query id. ``` -------------------------------- ### answerPreCheckoutQuery Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answer a PreCheckout query. ```APIDOC ## answerPreCheckoutQuery ### Description Answer a PreCheckout query. ### Method POST ### Endpoint answerPreCheckoutQuery(array $content) ### Parameters #### Request Body - **content** (array) - Required - PreCheckout query answer content. ### Response Returns the API response. ``` -------------------------------- ### Callback_ID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the callback_query id of the current update. ```APIDOC ## Callback_ID ### Description Get the callback_query id of the current update. ### Method GET ### Endpoint Callback_ID() ### Parameters None ### Response Returns the callback_query id. ``` -------------------------------- ### sendAudio Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send an audio. ```APIDOC ## sendAudio ### Description Send an audio. ### Parameters - **$content** (array) - Required - The parameters for sending an audio. ``` -------------------------------- ### createNewStickerSet Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Create New Sticker Set. ```APIDOC ## createNewStickerSet ### Description Create New Sticker Set. ### Method POST ### Endpoint createNewStickerSet(array $content) ### Parameters #### Request Body - **content** (array) - Required - Sticker set creation parameters. ### Response Returns the API response. ``` -------------------------------- ### ReplyToMessageID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the reply_to_message message_id of the current message. ```APIDOC ## ReplyToMessageID ### Description Get the reply_to_message message_id of the current message. ### Method GET ### Endpoint ReplyToMessageID() ### Parameters None ### Response Returns the message_id of the reply_to_message. ``` -------------------------------- ### setWebhook($url, $certificate = '') Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Sets a webhook for the bot. Specify a URL to receive incoming updates via an outgoing webhook. Optionally upload a public key certificate. ```APIDOC ## setWebhook($url, $certificate = '') ### Description Set a WebHook for the bot. 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. 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. ### Method setWebhook ### Parameters - **$url** (String) - Required - HTTPS url to send updates to. Use an empty string to remove webhook integration. - **$certificate** (InputFile) - Optional - Upload your public key certificate so that the root certificate in use can be checked. ### Returns - The JSON Telegram's reply. ``` -------------------------------- ### getChatMembersCount Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get chat member count (alias). ```APIDOC ## getChatMembersCount ### Description Get chat member count. ### Parameters - **$content** (array) - Required - The parameters for getting chat member count. ``` -------------------------------- ### addStickerToSet Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Add Sticker To Set. ```APIDOC ## addStickerToSet ### Description Add Sticker To Set. ### Method POST ### Endpoint addStickerToSet(array $content) ### Parameters #### Request Body - **content** (array) - Required - Sticker addition parameters. ### Response Returns the API response. ``` -------------------------------- ### sendVideo Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send a video. ```APIDOC ## sendVideo ### Description Send a video. ### Parameters - **$content** (array) - Required - The parameters for sending a video. ``` -------------------------------- ### UserID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get user's id of current message. ```APIDOC ## UserID ### Description Get user's id of current message. ### Method GET ### Endpoint UserID() ### Parameters None ### Response Returns the user's id. ``` -------------------------------- ### createChatInviteLink Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Create a chat invite link. ```APIDOC ## createChatInviteLink ### Description Create a chat invite link. ### Method POST ### Endpoint createChatInviteLink(array $content) ### Parameters #### Request Body - **content** (array) - Required - Parameters for creating invite link. ### Response Returns the API response. ``` -------------------------------- ### respondSuccess Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html A method for responding http to Telegram. ```APIDOC ## respondSuccess ### Description A method for responding http to Telegram. ``` -------------------------------- ### ReplyToMessageFromUserID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the reply_to_message forward_from user_id of the current message. ```APIDOC ## ReplyToMessageFromUserID ### Description Get the reply_to_message forward_from user_id of the current message. ### Method GET ### Endpoint ReplyToMessageFromUserID() ### Parameters None ### Response Returns the user_id of the forward_from in the reply_to_message. ``` -------------------------------- ### respondSuccess() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html A method for responding http to Telegram. Returns the HTTP 200 to Telegram. ```APIDOC ## respondSuccess() ### Description A method for responding http to Telegram. ### Method respondSuccess ### Parameters None ### Returns - **HTTP 200** - The HTTP 200 response to Telegram. ``` -------------------------------- ### MessageID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the message_id of the current message. Returns the String message_id. ```APIDOC ## MessageID() ### Description Get the message_id of the current message. ### Method MessageID ### Parameters None ### Returns - **String** - The message_id of the current message. ``` -------------------------------- ### setChatMenuButton Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set the chat menu button. ```APIDOC ## setChatMenuButton ### Description Set the chat menu button. ### Parameters - **$content** (array) - Required - The parameters for setting the chat menu button. ``` -------------------------------- ### FromChatID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get chat's id where current message forwarded from. ```APIDOC ## FromChatID ### Description Get chat's id where current message forwarded from. ### Method GET ### Endpoint FromChatID() ### Parameters None ### Response Returns the chat id where the message was forwarded from. ``` -------------------------------- ### serveUpdate($update) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Serves an update. Use this method to use built-in functions like Text() or Username() on a specific update. ```APIDOC ## serveUpdate($update) ### Description Serve an update. Use this method to use the built-in functions like Text() or Username() on a specific update. ### Method serveUpdate ### Parameters - **$update** (Integer) - Required - The index of the update in the updates array. ### Returns No return value documented. ``` -------------------------------- ### FromID Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get user's id of current forwarded message. ```APIDOC ## FromID ### Description Get user's id of current forwarded message. ### Method GET ### Endpoint FromID() ### Parameters None ### Response Returns the user's id of the forwarded message. ``` -------------------------------- ### uploadStickerFile Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Upload Sticker File. ```APIDOC ## uploadStickerFile ### Description Upload Sticker File. ### Method POST ### Endpoint uploadStickerFile(array $content) ### Parameters #### Request Body - **content** (array) - Required - Sticker file parameters. ### Response Returns the API response. ``` -------------------------------- ### serveUpdate Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Serve an update. ```APIDOC ## serveUpdate ### Description Serve an update. ### Method POST ### Endpoint serveUpdate($update) ### Parameters #### Request Body - **update** (mixed) - Required - The update to serve. ### Response Returns the result of serving the update. ``` -------------------------------- ### Callback_ChatID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Gets the chat_id of the current callback. Deprecated: Use ChatId() instead. ```APIDOC ## Callback_ChatID() ### Description Get the chat_id of the current callback. **Deprecated:** Use ChatId() instead. ### Method Callback_ChatID ### Returns - the String callback_query. ``` -------------------------------- ### answerPreCheckoutQuery(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answers a pre-checkout query. Accepts an array of request parameters and returns the JSON reply from Telegram. ```APIDOC ## answerPreCheckoutQuery(array $content) ### Description Answer a PreCheckout query. See answerPreCheckoutQuery for the input values. ### Method answerPreCheckoutQuery ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns The JSON Telegram's reply. ``` -------------------------------- ### uploadStickerFile(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Uploads a sticker file. Accepts an array of request parameters and returns the JSON Telegram reply. ```APIDOC ## uploadStickerFile(array $content) ### Description Upload Sticker File. See uploadStickerFile for the input values. ### Method uploadStickerFile ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns The JSON Telegram's reply. ``` -------------------------------- ### Keyboard Helper Functions Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Reference list of helper functions available for building and managing Telegram bot keyboards. ```text buildKeyBoard(array $options, $onetime=true, $resize=true, $selective=true) Send a custom keyboard. $option is an array of array KeyboardButton. Check ReplyKeyBoardMarkUp for more info. buildInlineKeyBoard(array $inline_keyboard) Send a custom keyboard. $inline_keyboard is an array of array InlineKeyboardButton. Check InlineKeyboardMarkup for more info. buildInlineKeyBoardButton($text, $url, $callback_data, $switch_inline_query) Create an InlineKeyboardButton. Check InlineKeyBoardButton for more info. buildKeyBoardButton($text, $url, $request_contact, $request_location) Create a KeyboardButton. Check KeyBoardButton for more info. buildKeyBoardHide($selective=true) Hide a custom keyboard. Check ReplyKeyBoarHide for more info. buildForceReply($selective=true) Show a Reply interface to the user. Check ForceReply for more info. ``` -------------------------------- ### ReplyToMessageID() Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Get the reply_to_message message_id of the current message. Returns the String reply_to_message message_id. ```APIDOC ## ReplyToMessageID() ### Description Get the reply_to_message message_id of the current message. ### Method ReplyToMessageID ### Parameters None ### Returns - **String** - The reply_to_message message_id. ``` -------------------------------- ### Send a Message Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Initialize the Telegram class, retrieve the chat ID, and send a text message. ```php $telegram = new Telegram('YOUR TELEGRAM TOKEN HERE'); $chat_id = $telegram->ChatID(); $content = array('chat_id' => $chat_id, 'text' => 'Test'); $telegram->sendMessage($content); ``` -------------------------------- ### close Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Closes the bot instance. ```APIDOC ## close ### Description Closes the bot instance. ``` -------------------------------- ### createNewStickerSet(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Creates a new sticker set. See createNewStickerSet for the input values. ```APIDOC ## createNewStickerSet(array $content) ### Description Create New Sticker Set. See createNewStickerSet for the input values. ### Method createNewStickerSet ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns - **JSON** - Telegram's reply. ``` -------------------------------- ### answerCallbackQuery Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answer a callback Query. ```APIDOC ## answerCallbackQuery ### Description Answer a callback Query. ### Parameters - **$content** (array) - Required - The parameters for answering a callback query. ``` -------------------------------- ### setMyCommands(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Sets the list of the bot commands. Accepts an array of request parameters and returns the JSON Telegram reply. ```APIDOC ## setMyCommands(array $content) ### Description Sets the list of the bot commands. ### Method setMyCommands ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns The JSON Telegram's reply. ``` -------------------------------- ### setChatTitle Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set Chat Title. ```APIDOC ## setChatTitle ### Description Set Chat Title. ### Method POST ### Endpoint setChatTitle(array $content) ### Parameters #### Request Body - **content** (array) - Required - Title parameters. ### Response Returns the API response. ``` -------------------------------- ### setChatDescription Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set Chat Description. ```APIDOC ## setChatDescription ### Description Set Chat Description. ### Method POST ### Endpoint setChatDescription(array $content) ### Parameters #### Request Body - **content** (array) - Required - Description parameters. ### Response Returns the API response. ``` -------------------------------- ### createChatInviteLink(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Creates a chat invite link. See createChatInviteLink for the input values. ```APIDOC ## createChatInviteLink(array $content) ### Description See createChatInviteLink for the input values. ### Method createChatInviteLink ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns - **JSON** - Telegram's reply. ``` -------------------------------- ### sendGame Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send a Game. ```APIDOC ## sendGame ### Description Send a Game. ### Method POST ### Endpoint sendGame(array $content) ### Parameters #### Request Body - **content** (array) - Required - Game content. ### Response Returns the API response. ``` -------------------------------- ### sendVenue Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send Venue. ```APIDOC ## sendVenue ### Description Send Venue. ### Parameters - **$content** (array) - Required - The parameters for sending a venue. ``` -------------------------------- ### sendSticker Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send a sticker. ```APIDOC ## sendSticker ### Description Send a sticker. ### Parameters - **$content** (array) - Required - The parameters for sending a sticker. ``` -------------------------------- ### answerCallbackQuery(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answers a callback query sent from an inline keyboard. Accepts an array of request parameters and returns the JSON reply from Telegram. ```APIDOC ## answerCallbackQuery(array $content) ### Description Answers a callback query. See answerCallbackQuery for the input values. ### Method answerCallbackQuery ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns The JSON Telegram's reply. ``` -------------------------------- ### setChatPhoto Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set Chat Photo. ```APIDOC ## setChatPhoto ### Description Set Chat Photo. ### Method POST ### Endpoint setChatPhoto(array $content) ### Parameters #### Request Body - **content** (array) - Required - Photo parameters. ### Response Returns the API response. ``` -------------------------------- ### answerShippingQuery Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answer a shipping query. ```APIDOC ## answerShippingQuery ### Description Answer a shipping query. ### Method POST ### Endpoint answerShippingQuery(array $content) ### Parameters #### Request Body - **content** (array) - Required - Shipping query answer content. ### Response Returns the API response. ``` -------------------------------- ### answerShippingQuery(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Answers a shipping query. Accepts an array of request parameters and returns the JSON reply from Telegram. ```APIDOC ## answerShippingQuery(array $content) ### Description Answer a shipping query. See answerShippingQuery for the input values. ### Method answerShippingQuery ### Parameters - **$content** (array) - Required - The request parameters as array. ### Returns The JSON Telegram's reply. ``` -------------------------------- ### promoteChatMember Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Promote Chat Member. ```APIDOC ## promoteChatMember ### Description Promote Chat Member. ### Method POST ### Endpoint promoteChatMember(array $content) ### Parameters #### Request Body - **content** (array) - Required - Promotion parameters. ### Response Returns the API response. ``` -------------------------------- ### Include via TelegramBotPHP Class Source: https://eleirbag89.github.io/TelegramBotPHP/md__r_e_a_d_m_e.html Manually include the Telegram.php file. Copy TelegramErrorLogger.php to the same directory to enable error logging. ```php include 'Telegram.php'; $telegram = new Telegram('YOUR TELEGRAM TOKEN HERE'); ``` -------------------------------- ### sendAudio(array $content) Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Sends an audio file to a chat. Accepts an array of request parameters and returns the JSON reply from Telegram. ```APIDOC ## sendAudio(array $content) ### Description Sends an audio file to a chat. Accepts an array of request parameters and returns the JSON reply from Telegram. ### Method POST ### Endpoint sendAudio ### Parameters #### Request Body - **$content** (array) - Required - The request parameters as an array. ### Returns - The JSON Telegram's reply. ``` -------------------------------- ### leaveChat Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Leave Chat. ```APIDOC ## leaveChat ### Description Leave Chat. ### Parameters - **$content** (array) - Required - The parameters for leaving a chat. ``` -------------------------------- ### setMyDefaultAdministratorRights Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set the default aministrator rights. ```APIDOC ## setMyDefaultAdministratorRights ### Description Set the default aministrator rights. ### Parameters - **$content** (array) - Required - The parameters for setting default administrator rights. ``` -------------------------------- ### setChatStickerSet Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set Chat Sticker Set. ```APIDOC ## setChatStickerSet ### Description Set Chat Sticker Set. ### Parameters - **$content** (array) - Required - The parameters for setting a chat sticker set. ``` -------------------------------- ### setData Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Set the data currently used. ```APIDOC ## setData ### Description Set the data currently used. ### Parameters - **$data** (array) - Required - The data to set. ``` -------------------------------- ### sendContact Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Send a contact. ```APIDOC ## sendContact ### Description Send a contact. ### Parameters - **$content** (array) - Required - The parameters for sending a contact. ``` -------------------------------- ### getUpdates Source: https://eleirbag89.github.io/TelegramBotPHP/class_telegram.html Receive incoming messages using polling. ```APIDOC ## getUpdates ### Description Receive incoming messages using polling. ### Method POST ### Endpoint getUpdates($offset=0, $limit=100, $timeout=0, $update=true) ### Parameters #### Query Parameters - **offset** (int) - Optional - Identifier of the first update to be returned. - **limit** (int) - Optional - Limits the number of updates to be retrieved. - **timeout** (int) - Optional - Timeout in seconds for long polling. - **update** (bool) - Optional - Whether to process the update. ### Response Returns the updates. ```