alisoftware / phptgbot
PHP Telegram Bot
0.1.5
2017-05-01 09:19 UTC
Requires
- php: >=5.4.0
- ext-curl: *
This package is not auto-updated.
Last update: 2025-06-08 05:30:38 UTC
README
PHP Telegram Bot
Installation
Using Composer
composer.json
:
{ "require": { "alisoftware/phptgbot": "*" } }
index.php
:
<?php require __DIR__ .'/vendor/autoload.php' ; use \Alisoftware\Phptgbot as Bot; Bot::setToken(''); Bot::getMe();
Longpooling / Webhook
Example:
<?php require __DIR__ .'/vendor/autoload.php' ; use \Alisoftware\Phptgbot as Bot; Bot::setToken(''); // webhook // Bot::setToken('TOKEN',true); Bot::run(function($response){ if ($response['error'] == false) { $message = isset($response['message'])?$response['message']:false; $onChannel = isset($response['channel_post'])?$response['channel_post']:false; if ($message != false) onMessage($message); //if ($onChannel != false) onMessage($onChannel); } }); function onMessage($message){ print_r($message); if ($message['text'] == 'ping') { Bot::send('message','<b>PONG!</b>'); } }