zelenin / telegram-bot-api
Telegram Bot API Client
Installs: 16 830
Dependents: 0
Suggesters: 0
Security: 0
Stars: 58
Watchers: 9
Forks: 21
Open Issues: 3
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~6.0
Suggests
- ext/pcntl: Usage of signal handler
This package is not auto-updated.
Last update: 2024-12-18 16:43:47 UTC
README
Installation
Composer
The preferred way to install this extension is through Composer.
Either run
php composer.phar require "zelenin/telegram-bot-api" "~1.0"
or add
"zelenin/telegram-bot-api": "~1.0"
to the require section of your composer.json
Usage
$api = ApiFactory::create($token); try { $response = $api->sendMessage([ 'chat_id' => $chatId, 'text' => 'Test message' ]); print_r($response); $response = $api->sendPhoto([ 'chat_id' => $myId, 'photo' => fopen('/home/www/photo.jpg', 'r') ]); print_r($response); } catch (\Zelenin\Telegram\Bot\Exception\NotOkException $e) { echo $e->getMessage(); }
See Bot API documentation for other methods.
Daemon
$api = ApiFactory::create($token); $daemon = new \Zelenin\Telegram\Bot\Daemon\NaiveDaemon($api); $daemon ->onUpdate(function (\Zelenin\Telegram\Bot\Type\Update $update) { print_r($update); }); $daemon->run();
Author
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me