telme / telme
Lightweight simple pusher to telegram bot API.
1.0.0
2019-10-16 17:49 UTC
Requires
- php: >=5.6
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 6.5.*
This package is auto-updated.
Last update: 2024-04-17 04:42:44 UTC
README
Telme is lightweight simple pusher to telegram bot.
Installation
$ composer require telme/telme
Usage
<?php
use Telme\TelegramPusher;
$telegramApiKey = 'telegram_api_key';
$pusher = new TelegramPusher($telegramApiKey);
try {
$response = $pusher->call('SendMessage', [
'chat_id' => '@testchat',
'text' => '*Example* text',
'parse_mode' => 'Markdown',
]);
} catch (Telme\Exceptions\CurlException | Telme\Exceptions\TelegramBotApiException $e) {
echo $e->getMessage(), PHP_EOL;
}
/**
Example response structure:
[
'ok' => true,
'result' => [
'message_id' => 84,
'chat' => [
'id' => -1001410394173,
'title' => 'test_channel',
'username' => 'testchannel',
'type' => 'channel',
],
'date' => 1571236539,
'text' => 'Test message',
'entities' => [
[
'offset' => 0,
'length' => 4,
'type' => 'bold',
],
],
],
]
*/
echo $response['result']['text'], PHP_EOL;
List of available action and parameters you can find here.
Author
Mazur Alexandr - alexandrmazur96@gmail.com - https://t.me/alexandrmazur96
License
Telme is licensed under the GNU General Public License - see the LICENSE file for details.