Available Methods & Examples
Available Methods
The library supports all the methods listed on Telegram Bot API docs page.
sendMessage - Send a Message
See sendMessage docs for a list of supported parameters and other info.
- Standalone
- Laravel
$response = $telegram->sendMessage('CHAT_ID', 'Hello World');
$messageId = $response->getMessageId();
$response = Telegram::sendMessage('CHAT_ID', 'Hello World');
$messageId = $response->getMessageId();
forwardMessage - Forward a Message
See forwardMessage docs for a list of supported parameters and other info.
- Standalone
- Laravel
$response = $telegram->forwardMessage('CHAT_ID', 'FROM_CHAT_ID', 'MESSAGE_ID');
$messageId = $response->getMessageId();
$response = Telegram::forwardMessage('CHAT_ID', 'FROM_CHAT_ID', 'MESSAGE_ID');
$messageId = $response->getMessageId();
sendPhoto - Send a Photo
See sendPhoto docs for a list of supported parameters and other info.
- Standalone
- Laravel
$response = $telegram->sendPhoto('CHAT_ID', 'path/to/photo.jpg', 'Some caption');
$messageId = $response->getMessageId();
$response = Telegram::sendPhoto('CHAT_ID', 'path/to/photo.jpg', 'Some caption');
$messageId = $response->getMessageId();
sendChatAction - Send a Chat Action
See sendChatAction docs for a list of supported actions and other info.
- Standalone
- Laravel
$response = $telegram->sendChatAction('CHAT_ID', 'typing');
$messageId = $response->getMessageId();
$response = Telegram::sendChatAction('CHAT_ID', 'typing');
$messageId = $response->getMessageId();
There is also a helper method for supplying the chat action. This is especially useful with code completion with your IDE.
$telegram->sendChatAction('CHAT_ID', Actions::RECORD_VIDEO);
getUserProfilePhotos - Get User Profile Photos
See getUserProfilePhotos docs for a list of supported parameters and other info.
- Standalone
- Laravel
$response = $telegram->getUserProfilePhotos('USER_ID');
$photos_count = $response->getTotalCount();
$photos = $response->getPhotos();
$response = Telegram::getUserProfilePhotos('USER_ID');
$photos_count = $response->getTotalCount();
$photos = $response->getPhotos();
getUpdates - Get Updates
See getUpdates docs for a list of supported parameters and other info.
- Standalone
- Laravel
$updates = $telegram->getUpdates();
$updates = Telegram::getUpdates();