alexvkokin / telegram-bot-api
Telegram Bot Api
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/alexvkokin/telegram-bot-api
Requires
- php: ^8.2
 - php-http/multipart-stream-builder: ^1.4.2
 - psr/http-client: ^1.0
 - psr/http-factory: ^1.1
 - psr/http-message: ^1.1|^2.0
 - psr/log: ^3.0
 
Requires (Dev)
- guzzlehttp/guzzle: *
 - httpsoft/http-message: ^1.1
 - maglnet/composer-require-checker: ^4.11
 - monolog/monolog: ^3.7
 - phpunit/phpunit: ^10.5
 - vimeo/psalm: ^5.26
 
README
Requirements
- PHP 8.2 or higher.
 
Installation
The package could be installed with Composer:
composer require alexvkokin/telegram-bot-api
Example
use Alexvkokin\TelegramBotApi\Client\TelegramClient; use Alexvkokin\TelegramBotApi\Method\SendMessage; use Alexvkokin\TelegramBotApi\Method\SendPhoto; use Alexvkokin\TelegramBotApi\Method\GetMe; use Alexvkokin\TelegramBotApi\TelegramBotApi; use Alexvkokin\TelegramBotApi\Type\InputFile; use GuzzleHttp\Client; use HttpSoft\Message\RequestFactory; use HttpSoft\Message\StreamFactory; require_once __DIR__ . '/../../vendor/autoload.php'; $token = 'YOUR_BOT_TOKEN'; $chatId = 123456789; // Telegram API BOT client $api = new TelegramBotApi( $token, new TelegramClient( new Client(), new RequestFactory(), new StreamFactory(), ) ); // get bot info $method = new GetMe(); $response = $api->send($method); // send message $method = new SendMessage( chat_id: $chatId, text: 'Hello, world!', ); $response = $api->send($method); // send local file $method = new SendPhoto( chat_id: $chatId, photo: InputFile::withLocalFile(__DIR__.'/../imgs/screen.png', 'screenshot 1'), ); $response = $api->send($method);