yabx / telegram
Telegram Bot API SDK for PHP 8.1+
Installs: 1 543
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.9
- psr/log: ^3.0
Requires (Dev)
- ext-mbstring: *
README
- Bot API 8.1 (December 4, 2024)
- HTTP-Client based on Guzzle
- Full support of all available types according https://core.telegram.org/bots/api#available-types
- Full support of all available methods according https://core.telegram.org/bots/api#available-methods
Installation
composer req yabx/telegram
Sending messages
use Yabx\Telegram\BotApi; // Create an BotApi client instance $tg = new BotApi('123:qwe'); // Sending message $message = $tg->sendMessage(12345, 'Hello World!');
Working with webhooks
use Yabx\Telegram\BotApi; // Create an BotApi client instance $tg = new BotApi('123:qwe'); // Set webhook $tg->setWebhook('https://tg.myservice.com/bot123'); // Get webhook info $webhook = $tg->getWebhookInfo();
Receiving updates from webhook
use Yabx\Telegram\BotApi; // Parse telegram webhook $update = BotApi::getUpdateFromRequest(); // or $update = BotApi::getUpdateFromJson($json); // Get Message object $message = $update->getMessage(); // Get Sender and Chat objects $sender = $message->getFrom(); $chat = $message->getChat(); // Get some message attributes $text = $message->getText(); $video = $message->getVideo(); $photos = $message->getPhotos(); $document = $message->getDocument();