PHP code example of zafarjonovich / yii-telegram-notification

1. Go to this page and download the library: Download zafarjonovich/yii-telegram-notification 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/ */

    

zafarjonovich / yii-telegram-notification example snippets




$config = [
 ...
 'components' => [
 ...
	  'telegramNotification' => [
            'class' => \zafarjonovich\YiiTelegramNotification\YiiTelegramNotificationComponent::class,
            'bot_token' => 'BOT_TOKEN_HERE'
        ],

];




// Sending text message

\Yii::$app->telegramNotification->send('chat_id',[
    'text' => "Hello world"
]);

// Sending photo message, this example text will be comment of photo

\Yii::$app->telegramNotification->send('chat_id',[
    'photo' => "PHOTO_URL",
    'text' => "Hello world",
]);


// Sending video message, this example text will be comment of video

\Yii::$app->telegramNotification->send('chat_id',[
    'video' => "VIDEO_URL",
    'text' => "Hello world",
]);

// Send message multiple chats

\Yii::$app->telegramNotification->multipleSend(['chat_id1','chat_id2'],[
    'text' => "Hello world"
]);