1. Go to this page and download the library: Download uzdevid/yii2-telegram 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/ */
$telegram->bot->handler->onMessage('/start', function ($body) use ($telegram) {
// Your code
$telegram->bot->sender->text("Welcome")->send();
});
$telegram->bot->handler->onCommand('/callback', function ($body, $callback_data) use ($telegram) {
// Your code
$telegram->bot->sender->photo('/img/elephant.jpg')->send();
});
$telegram->bot->handler->onQuery('*', function ($query, $body) use ($telegram) {
// Your code
$title = "Mode: InlineQuery";
$description = "Query: {$query}";
$content = "Answer content";
$telegram->bot->sender->inline
->answer([$telegram->bot->sender->inline->article($title, $description, $content)])
->send();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.