Package Data | |
---|---|
Maintainer Username: | ricardofontanelli |
Maintainer Contact: | ricardo.fontanelli@hotmail.com (Ricardo Fontanelli) |
Package Create Date: | 2017-02-14 |
Package Last Update: | 2023-01-20 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-14 15:11:56 |
Package Statistics | |
---|---|
Total Downloads: | 3,609 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 10 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 1 |
A simple and lightweight Laravel 4.2 and Laravel 5.* wrapper to interact with Telegram Bot.
composer require ricardofontanelli/laravel-telegram:1.0
or Composer by requiring the ricardofontanelli/laravel-telegram
package in your project's composer.json
{
"require": {
"ricardofontanelli/laravel-telegram": "1.0"
}
}
Then run a composer update
php composer update
In Laravel find the providers
key in your config/app.php
and register the Laravel Telegram Service Provider.
'providers' => array(
// ...
'RicardoFontanelli\LaravelTelegram\TelegramServiceProvider',
)
Find the aliases
key in your config/app.php
and add the Laravel Telegram facade alias.
'aliases' => array(
// ...
'Telegram' => 'RicardoFontanelli\LaravelTelegram\TelegramFacade',
)
Now, you should publish the package to generate the config file, after that, edit the config file with your Telegram Bot credentials.
The config file will be generate here: app/config/packages/ricardofontanelli/laravel-telegram/config.php
php artisan config:publish ricardofontanelli/laravel-telegram
The config file will be generate here: app/config/telegram.php
php artisan vendor:publish --provider="RicardoFontanelli\LaravelTelegram\TelegramServiceProvider"
Now you can use it by php artisan tinker
and run:
// Send a message
Telegram::sendMessage('default', 'Here we go!');
// or async
Telegram::async()->sendMessage('default', 'Here we go!');
The first value is the config key name of the chat/group id where the Bot will publicate the message, you can provide the chat/group id directly.
// Send an async message
Telegram::getMe()->getResult();
// Send an async message
Telegram::getUpdates()->getResult();
The class has use a magic method to call unsuported methods:
$params = ['method'=>'GET'];
Telegram::getWebhookInfo($params)->getResult()
You can use the variable $params
to send query parameters and define the HTTP method (according the Telegram Bot Api documentation).
You can find more here (Telegram Bot API)[https://core.telegram.org/bots/api], but if you need to call a method that the class doesn't support, feel free to send a PR.