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.
$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.
$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.
$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.
$telegram->sendChatAction('CHAT_ID', 'upload_photo');
Telegram::sendChatAction('CHAT_ID', 'upload_photo');
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);
Telegram::sendChatAction('CHAT_ID', Actions::RECORD_VIDEO);
getUserProfilePhotos - Get User Profile Photos
See getUserProfilePhotos docs for a list of supported parameters and other info.
$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.
$updates = $telegram->getUpdates();
$updates = Telegram::getUpdates();
Updated less than a minute ago