PHP code example of umedzhan / telegram-php

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

    

umedzhan / telegram-php example snippets




elegram\Bot\Telegram;

$telegram = new Telegram('ТОКЕНИ_БОТИ_ТЕЛЕГРАМ');

$telegram->sendMessage(123456778, 'Салом дунё');



elegram\Bot\Telegram;

$telegram = new Telegram('ТОКЕНИ_БОТИ_ТЕЛЕГРАМ');

if ($telegram->isMessage()) {

    $chat_id = $telegram->ChatID();
    $text = $telegram->Text();

    if ($text == '/start') {
        $telegram->sendMessage($chat_id, 'Салом хуш омадед!');
    }
}



use Telegram\Bot\Keyboard;

$keyboard = new ReplyKeyboardMarkup(
    [
        [
            new KeyboardButton('Якум'),
            new KeyboardButton('Дуюм'),
        ],
        [
            new KeyboardButton('Сеюм'),
        ]
    ]
);

$telegram->sendMessage($chat_id, 'Тугмаҳо', reply_markup: $keyboard);
bash
composer