A Class of all Telegram Bot Methods for PHP
Method Name | Description |
---|---|
getUpdates | Use this method to receive incoming updates using long polling. |
setWebhook | Use this method to specify a url and receive incoming updates via an outgoing webhook |
deleteWebhook | Use this method to remove webhook integration if you decide to switch back to getUpdates |
getWebhookInfo | Use this method to get current webhook status. Requires no parameters |
getme | A simple method for testing your bot's auth token |
sendMessage | Use this method to send text messages |
forwardMessage | Use this method to forward messages of any kind |
sendPhoto | Use this method to send photos |
sendAudio | 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. |
sendDocument | Use this method to send general files |
sendVideo | Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document) |
sendAnimation | Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound) |
sendVoice | 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) |
sendVideoNote | As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages |
sendMediaGroup | Use this method to send a group of photos or videos as an album |
sendLocation | Use this method to send point on the map |
editMessageLiveLocation | Use this method to edit live location messages sent by the bot or via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation |
stopMessageLiveLocation | Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires. |
sendVenue | Use this method to send information about a venue |
sendContact | Use this method to send phone contacts |
sendPoll | Use this method to send a native poll. A native poll can't be sent to a private chat |
sendChatAction | Use this method when you need to tell the user that something is happening on the bot's side. |
getUserProfilePhotos | Use this method to get a list of profile pictures for a user |
getFile | 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 |
getFileLink | Use this method to get File link |
kickChatMember | Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first |
unbanChatMember | Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc |
restrictChatMember | Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights |
promoteChatMember | Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
exportChatInviteLink | Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
setChatPhoto | Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
deleteChatPhoto | Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
setChatTitle | Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
setChatDescription | Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
pinChatMessage | Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel |
unpinChatMessage | Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel |
leaveChat | Use this method for your bot to leave a group, supergroup or channel |
getChat | 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.) |
getChatAdministrators | Use this method to get a list of administrators in a chat |
getChatMembersCount | Use this method to get the number of members in a chat |
getChatMember | Use this method to get information about a member of a chat |
setChatStickerSet | Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
deleteChatStickerSet | Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights |
answerCallbackQuery | Use this method to send answers to callback queries sent from inline keyboards |
answerInlineQuery | Use this method to send answers to an inline query |
editMessageText | Use this method to edit text and game messages sent by the bot or via the bot (for inline bots) |
editMessageCaption | Use this method to edit captions of messages sent by the bot or via the bot (for inline bots) |
editMessageMedia | Use this method to edit audio, document, photo, or video messages |
editMessageReplyMarkup | Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots) |
stopPoll | Use this method to stop a poll which was sent by the bot |
deleteMessage | Use this method to delete a message |
sendSticker | Use this method to send .webp stickers |
getStickerSet | Use this method to get a sticker set |
uploadStickerFile | Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times) |
createNewStickerSet | Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set |
addStickerToSet | Use this method to add a new sticker to a set created by the bot |
setStickerPositionInSet | Use this method to move a sticker in a set created by the bot to a specific position |
deleteStickerFromSet | Use this method to delete a sticker from a set created by the bot |
sendInvoice | Use this method to send invoices |
answerShippingQuery | Use this method to reply to shipping queries |
answerPreCheckoutQuery | Use this method to respond to such pre-checkout queries |
setPassportDataErrors | Informs a user that some of the Telegram Passport elements they provided contains errors |
sendGame | Use this method to send a game |
setGameScore | Use this method to set the score of the specified user in a game |
getGameHighScores | Use this method to get data for high score tables |
First you need to include class file and initialize the class:
<?php
require_once 'BotMethod.php'; //include class file
$tg = new \MohsenJS\BotMethod("**YOUR_TOKEN**"); //initialize the class
For testing, we send a message and photo
<?php
require_once 'BotMethod.php'; //include class file
$tg = new \MohsenJS\BotMethod("**YOUR_TOKEN**"); //initialize the class
$tg->sendMessage(123456789, 'Hello World!'); //send message
$tg->sendPhoto(123456789, 'https://www.w3schools.com/html/img_girl.jpg', ':)'); //send photo with caption