PHP Telegram Wrapper
, (*1)
PHP wrapper for Telegram bots, (*2)
Install
This project uses Composer. To use the project, just add it to your dependencies., (*3)
``` bash
$ composer require hetisniels/telegram-wrapper, (*4)
**Without Composer**
It is possible you dont like Composer or you just want to get the source and use it. In this case download the latest release in releases page.
Note: You need to make your own autoloader for this to work!
## Sample usage
### Telegram\Bot
``` php
<?php
class HelloWorldCommand implements \Telegram\Commands\ICommand
{
public function call($name, $arguments, $caller)
{
$keyboard = $caller->getBot()->createKeyboard(); // Alternative: $keyboard = new KeyboardBuilder();
$keyboard = $keyboard->button('A')->button('B')->row()->button('C')->button('D')->row()->setResizable(true)->setOneTime(true)->keyboard();
$caller->reply('Hello World!', false, $keyboard);
}
public function getDescription()
{
return 'Sends the popular "Hello World" text.';
}
public function getUsage()
{
return '<command>';
}
}
$bot = new Telegram\Bot('API_TOKEN');
$bot->addCommand('helloworld', new HelloWorldCommand());
$bot->work();
And now, just send the message "/helloworld" to the bot!, (*5)
Telegram\Api
``` php
<?php
$bot = new Telegram\Api('API_TOKEN');, (*6)
$bot->getUpdates(); // Returns array of Update
```
An custom command handler is needed when using the API.
The API provides only the methods & types from Telegram., (*7)