PHP code example of mirkhamidov / yii2-bot-telegram

1. Go to this page and download the library: Download mirkhamidov/yii2-bot-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/ */

    

mirkhamidov / yii2-bot-telegram example snippets



'components' => [
	'telegram' => [
        'class' => 'mirkhamidov\telegramBot\TelegramBot',
        'botToken' => 'TOKEN HERE',
    ]
]

 Yii::$app->telegram->sendMessage('Message'); 

 Yii::$app->telegram->sendMessage('Message with inline keyboard', $chatId, [
        'reply_markup' => json_encode([
            'inline_keyboard'=>[
                [
                    ['text'=>"refresh",'callback_data'=> time()]
                ]
            ]
        ]),
    ] 

 Yii::$app->telegram->sendPhoto('/app/pattern2.jpg', $chatId, [
    'caption' => 'some text',
]); 

php composer.phar