PhpBotFramework  2.0.2
A framework for Telegram Bots' APIs.
Functions
Api Methods

Implementations for Telegram Bot API's methods. More...

Functions

Array false PhpBotFramework\Core\Chat::getMe ()
 A simple method for testing bot's auth token. More...
 
Array false PhpBotFramework\Core\Chat::getChat ($chat_id)
 Get info about a chat. More...
 
Array false PhpBotFramework\Core\Chat::getChatAdministrators ($chat_id)
 Use this method to get the list of chat's administrators. More...
 
mixed PhpBotFramework\Core\CoreBot::apiRequest (string $method, array $parameters)
 Execute any API request using this method. More...
 
Message false PhpBotFramework\Core\Edit::editMessageText (int $message_id, string $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=true)
 Edit text of a message sent by the bot. More...
 
bool PhpBotFramework\Core\Edit::editInlineMessageText (string $inline_message_id, string $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false)
 Edit text of a message sent via the bot. More...
 
Message false PhpBotFramework\Core\Edit::editMessageReplyMarkup (int $message_id, string $inline_keyboard)
 Edit only the inline keyboard of a message. More...
 
bool PhpBotFramework\Core\Inline::answerCallbackQuery ($text='', $show_alert=false, string $url='')
 Answer a callback query. More...
 
bool PhpBotFramework\Core\Inline::answerInlineQuery (string $results='', string $switch_pm_text='', $switch_pm_parameter='', bool $is_personal=true, int $cache_time=300)
 Answer a inline query (when the user write "Query") with a button, that will make user switch to the private chat with the bot, on the top of the results. Api reference More...
 
Message false PhpBotFramework\Core\Send::sendMessage ($text, string $reply_markup=null, int $reply_to=null, string $parse_mode='HTML', bool $disable_web_preview=true, bool $disable_notification=false)
 Send a text message. More...
 
Message false PhpBotFramework\Core\Send::forwardMessage ($from_chat_id, int $message_id, bool $disable_notification=false)
 Forward a message. More...
 
Message false PhpBotFramework\Core\Send::sendPhoto (&$photo, string $reply_markup=null, string $caption='', bool $disable_notification=false)
 Send a photo. More...
 
Message false PhpBotFramework\Core\Send::sendAudio ($audio, string $caption=null, string $reply_markup=null, int $duration=null, string $performer, string $title=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send an audio. More...
 
Message false PhpBotFramework\Core\Send::sendDocument (string $document, string $caption='', string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send a document. More...
 
Message false PhpBotFramework\Core\Send::sendSticker ($sticker, string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send a sticker. More...
 
Message false PhpBotFramework\Core\Send::sendVoice ($voice, string $caption, int $duration, string $reply_markup=null, bool $disable_notification, int $reply_to_message_id=0)
 Send audio files. More...
 
bool PhpBotFramework\Core\Send::sendChatAction (string $action)
 Say the user what action bot's going to do. More...
 
 PhpBotFramework\Core\Updates::setWebhook (array $params)
 Set bot's webhook. More...
 
Array false PhpBotFramework\Core\Updates::getWebhookInfo ()
 Get information about bot's webhook. More...
 
 PhpBotFramework\Core\Updates::deleteWebhook ()
 Delete bot's webhook. More...
 
Array false PhpBotFramework\Core\Updates::getUpdates (int $offset=0, int $limit=100, int $timeout=60)
 Request bot updates. More...
 
 PhpBotFramework\Core\Updates::setUpdateReturned (array $allowed_updates=[])
 Set updates received by the bot for getUpdates handling. More...
 

Detailed Description

Implementations for Telegram Bot API's methods.

Function Documentation

◆ answerCallbackQuery()

bool PhpBotFramework\Core\Inline::answerCallbackQuery (   $text = '',
  $show_alert = false,
string  $url = '' 
)

Answer a callback query.

Remove the 'updating' circle icon on an inline keyboard button showing a message/alert to the user. It'll always answer the current callback query. Api reference

Parameters
string$textOptional. Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.
bool$show_alertOptional. If true, an alert will be shown by the client instead of a notification at the top of the chat screen.
string$urlOptional. URL that will be opened by the user's client. If you have created a Game and accepted the conditions via , specify the URL that opens your game – note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like telegram.me/your_bot?start=XXXX that open your bot with a parameter.
Returns
bool True on success.

◆ answerInlineQuery()

bool PhpBotFramework\Core\Inline::answerInlineQuery ( string  $results = '',
string  $switch_pm_text = '',
  $switch_pm_parameter = '',
bool  $is_personal = true,
int  $cache_time = 300 
)

Answer a inline query (when the user write "Query") with a button, that will make user switch to the private chat with the bot, on the top of the results. Api reference

Parameters
string$resultsA JSON-serialized array of results for the inline query. Use PhpBotFramework class to create and get them.
string$switch_pm_textIf 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.
bool$is_personalPass 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.
int$cache_timeThe maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
Returns
bool True on success.

◆ apiRequest()

mixed PhpBotFramework\Core\CoreBot::apiRequest ( string  $method,
array  $parameters 
)

Execute any API request using this method.

Use this method for custom api calls using this syntax:

$param = [
        'chat_id' => $_chat_id,
        'text' => 'Hello!'
];
apiRequest("sendMessage", $param);
Parameters
string$methodThe method to call.
array$parametersParameters to add.
Returns
mixed Depends on api method.

◆ deleteWebhook()

PhpBotFramework\Core\Updates::deleteWebhook ( )

Delete bot's webhook.

Delete bot's webhook if it exists.

◆ editInlineMessageText()

bool PhpBotFramework\Core\Edit::editInlineMessageText ( string  $inline_message_id,
string  $text,
string  $reply_markup = null,
string  $parse_mode = 'HTML',
bool  $disable_web_preview = false 
)

Edit text of a message sent via the bot.

Use this method to edit text messages sent via the bot (for inline queries). API reference

Parameters
string$inline_message_idIdentifier of the inline message.
string$textNew text of the message.
string$reply_markupReply markup of the message will have (will be removed if this is null).
string$parse_modeOptional. Send Markdown or HTML.
bool$disable_web_previewOptional. Disables link previews for links in this message.
Returns
bool True on success.

◆ editMessageReplyMarkup()

Message false PhpBotFramework\Core\Edit::editMessageReplyMarkup ( int  $message_id,
string  $inline_keyboard 
)

Edit only the inline keyboard of a message.

API reference

Parameters
int$message_idIdentifier of the message to edit
string$inline_keyboardInlike keyboard array. API reference
Returns
Message|false Message edited, false otherwise.

◆ editMessageText()

Message false PhpBotFramework\Core\Edit::editMessageText ( int  $message_id,
string  $text,
string  $reply_markup = null,
string  $parse_mode = 'HTML',
bool  $disable_web_preview = true 
)

Edit text of a message sent by the bot.

Use this method to edit text and game messages sent by the bot. API reference

Parameters
int$message_idUnique identifier of the sent message.
string$textNew text of the message.
string$reply_markupReply markup of the message will have (will be removed if this is null).
string$parse_modeOptional. Send Markdown or HTML.
bool$disable_web_previewOptional. Disables link previews for links in this message.
Returns
Message|false Message edited, false otherwise.

◆ forwardMessage()

Message false PhpBotFramework\Core\Send::forwardMessage (   $from_chat_id,
int  $message_id,
bool  $disable_notification = false 
)

Forward a message.

Use this method to forward messages of any kind. API reference

Parameters
$from_chat_idThe chat where the original message was sent.
$message_idMessage identifier (id).
$disable_notificationOptional. Sends the message silently.
Returns
Message|false Message sent on success, false otherwise.

◆ getChat()

Array false PhpBotFramework\Core\Chat::getChat (   $chat_id)

Get info about a chat.

Use this method to get information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). API reference

Parameters
int | string$chat_idUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
Array|false Information about the chat.

◆ getChatAdministrators()

Array false PhpBotFramework\Core\Chat::getChatAdministrators (   $chat_id)

Use this method to get the list of chat's administrators.

Parameters
string$chat_idUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
Array|false 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.

◆ getMe()

Array false PhpBotFramework\Core\Chat::getMe ( )

A simple method for testing bot's auth token.

Requires no parameters. Returns basic information about the bot

Returns
Array|false Bot info

◆ getUpdates()

Array false PhpBotFramework\Core\Updates::getUpdates ( int  $offset = 0,
int  $limit = 100,
int  $timeout = 60 
)

Request bot updates.

Request updates received by the bot using method getUpdates of Telegram API. API reference

Parameters
int$offsetOptional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
int$limitOptional. Limits the number of updates to be retrieved. Values between 1—100 are accepted.
int$timeoutOptional. Timeout in seconds for long polling.
Returns
Array|false Array of updates (can be empty).

◆ getWebhookInfo()

Array false PhpBotFramework\Core\Updates::getWebhookInfo ( )

Get information about bot's webhook.

Returns an hash which contains information about bot's webhook.

Returns
Array|false Webhook info.

◆ sendAudio()

Message false PhpBotFramework\Core\Send::sendAudio (   $audio,
string  $caption = null,
string  $reply_markup = null,
int  $duration = null,
string  $performer,
string  $title = null,
bool  $disable_notification = false,
int  $reply_to_message_id = null 
)

Send an audio.

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. API reference Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

Parameters
$audioAudio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or give the local path of an audio to upload.
$captionOptional. Audio caption, 0-200 characters.
$reply_markupOptional. Reply markup of the message.
$durationOptional. Duration of the audio in seconds.
$performerOptional. Performer.
$titleOptional. Track name.
$disable_notificationOptional. Sends the message silently.
$reply_to_message_idOptional. If the message is a reply, ID of the original message.
Returns
Message|false Message sent on success, false otherwise.

◆ sendChatAction()

bool PhpBotFramework\Core\Send::sendChatAction ( string  $action)

Say the user what action bot's going to do.

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). API reference

Parameters
string$actionType 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
Returns
bool True on success.

◆ sendDocument()

Message false PhpBotFramework\Core\Send::sendDocument ( string  $document,
string  $caption = '',
string  $reply_markup = null,
bool  $disable_notification = false,
int  $reply_to_message_id = null 
)

Send a document.

Use this method to send general files. API reference

Parameters
string$documentFile to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or give the local path of an document to upload it. Only some document are allowed through url sending (this is a Telegram limitation).
string$captionOptional. Document caption (may also be used when resending documents by file_id), 0-200 characters.
string$reply_markupOptional. Reply markup of the message.
bool$disable_notificationOptional. Sends the message silently.
int$reply_to_message_idOptional. If the message is a reply, ID of the original message.
Returns
Message|false Message sent on success, false otherwise.

◆ sendMessage()

Message false PhpBotFramework\Core\Send::sendMessage (   $text,
string  $reply_markup = null,
int  $reply_to = null,
string  $parse_mode = 'HTML',
bool  $disable_web_preview = true,
bool  $disable_notification = false 
)

Send a text message.

Use this method to send text messages. API reference

Parameters
$textText of the message.
$reply_markupOptional. Reply_markup of the message.
$parse_modeOptional. Parse mode of the message.
$disable_web_previewOptional. Disables link previews for links in this message.
$disable_notificationOptional. Sends the message silently.
Returns
Message|false Message sent on success, false otherwise.

◆ sendPhoto()

Message false PhpBotFramework\Core\Send::sendPhoto ( $photo,
string  $reply_markup = null,
string  $caption = '',
bool  $disable_notification = false 
)

Send a photo.

Use this method to send photos. API reference

Parameters
$photoPhoto to send, can be a file_id or a string referencing the location of that image(both local or remote path).
$reply_markupOptional. Reply markup of the message.
$captionOptional. Photo caption (may also be used when resending photos by file_id), 0-200 characters.
$disable_notificationOptional. Sends the message silently.
Returns
Message|false Message sent on success, false otherwise.

◆ sendSticker()

Message false PhpBotFramework\Core\Send::sendSticker (   $sticker,
string  $reply_markup = null,
bool  $disable_notification = false,
int  $reply_to_message_id = null 
)

Send a sticker.

Use this method to send .webp stickers. API reference

Parameters
mixed$stickerSticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data.
string$reply_markupOptional. Reply markup of the message.
bool$disable_notificationSends the message silently.
int$reply_to_message_idOptional. If the message is a reply, ID of the original message.
boolOn success, the sent message.
Returns
Message|false Message sent on success, false otherwise.

◆ sendVoice()

Message false PhpBotFramework\Core\Send::sendVoice (   $voice,
string  $caption,
int  $duration,
string  $reply_markup = null,
bool  $disable_notification,
int  $reply_to_message_id = 0 
)

Send audio files.

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).o Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

Parameters
mixed$voiceAudio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or the local path of a voice to upload.
string$captionOptional. Voice message caption, 0-200 characters
int$durationOptional. Duration of the voice message in seconds
string$reply_markupOptional. Reply markup of the message.
bool$disable_notificationOptional. Sends the message silently.
int$reply_to_message_idOptional. If the message is a reply, ID of the original message.
Returns
Message|false Message sent on success, false otherwise.

◆ setUpdateReturned()

PhpBotFramework\Core\Updates::setUpdateReturned ( array  $allowed_updates = [])

Set updates received by the bot for getUpdates handling.

List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. Specify an empty list to receive all updates regardless of type. Set it one time and it won't change until next setUpdateReturned call.

Parameters
Array$allowed_updatesOptional. List of updates allowed.

◆ setWebhook()

PhpBotFramework\Core\Updates::setWebhook ( array  $params)

Set bot's webhook.

Set a webhook for the current bot in order to receive incoming updates via an outgoing webhook.

Parameters
$paramsSee Telegram API for more information about the available parameters.