PHP code example of maatify / telegram-bot

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

    

maatify / telegram-bot example snippets


use Maatify\TelegramBot\TelegramBotManager;

API_KEY__); // instance of bot manager

$response = $telegram->Methods()->GetMe(); // get bot account information

print_r($response);

$logout = $telegram->Methods()->Logout();
print_r($logout);

$close = $telegram->Methods()->Close();
print_r($close);

$chat = $telegram->GetChat(123456); // set getChat by chat_id

$by_chat                = $chat->Get();                 // get array of getChat
$chat_id                = $chat->GetID();               // get id from getChat by chat_id
$chat_first_name        = $chat->GetFirstName();        // get first_name from getChat
$chat_last_name         = $chat->GetLastName();         // get last_name from getChat
$chat_username          = $chat->GetUsername();         // get username from getChat
$chat_type              = $chat->GetType();             // get type from getChat
$chat_active_username   = $chat->GetActiveUsername();   // get array of active_username from getChat

try {
    $telegram->Downloader()->DownloadUserProfilePhotos($user_id);
} catch (Exception $e) {
    print_r($e->getMessage());
}