PHP code example of alisoftware / phptgbot
1. Go to this page and download the library: Download alisoftware/phptgbot library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alisoftware / phptgbot example snippets
Alisoftware\Phptgbot as Bot;
Bot::setToken('');
Bot::getMe();
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>');
}
}