https://github.com/stajor/telegram-bot
PHP Telegram Bot based on the official Telegram Bot API
https://github.com/stajor/telegram-bot
php telegram
Last synced: 5 months ago
JSON representation
PHP Telegram Bot based on the official Telegram Bot API
- Host: GitHub
- URL: https://github.com/stajor/telegram-bot
- Owner: Stajor
- License: mit
- Created: 2018-06-12T15:28:03.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-03-30T06:23:32.000Z (about 4 years ago)
- Last Synced: 2025-07-28T07:10:55.656Z (11 months ago)
- Topics: php, telegram
- Language: PHP
- Size: 85.9 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PHP Telgram Bot API
PHP wrapper for [Telegram's Bot API](https://core.telegram.org/bots/api).

[](https://travis-ci.org/Stajor/telegram-bot)
## Installation
Add this line to your application's composer.json:
```json
{
"require": {
"stajor/telegram-bot": "^3.0"
}
}
```
and run `composer update`
**Or** run this command in your command line:
$ composer require stajor/telegram-bot
## Telegram API support
All types and methods of the Telegram Bot API 3.6 are supported.
## Configuration
First of all you need create your own bot and obtain a token
[How do I create a bot?](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
## Usage
You can use **Telegram::Bot::Api** standalone
```php
getMe();
```
Or by using **CommandsHandler** to receive updates from Telegram
Create command class
```php
replyWithMessage(['text' => 'Welcome to my Bot']);
// Trigger another command dynamically from within this command
$this->triggerCommand('help');
}
}
```
In your controller add
```php
addCommand(StartCommand::class);
$handler->handle();
```
#### Send Photo
```php
$api = new \Telegram\Bot\Api('BOT TOKEN');
$api->sendPhoto(['chat_id' => 123,'photo' => fopen('path_to_photo', 'rb')]);
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Stajor/telegram-bot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).