PHP code example of albreis / telegram

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

    

albreis / telegram example snippets



use Albreis\Telegram\Bot;
use Albreis\Telegram\Config;

(getenev('TELEGRAM_BOT_TOKEN'));

/**
 * Utilize parâmetros/argumentos nomeados (Named Arguments / Named Parameters)
 */
$response = Bot::sendMessage(
    chat_id: $chat_id,
    text: 'Test message'
);

var_dump($response);

/**
 * É possível definir o token durante a chamada
 * Isso irá retornar uma nova instância
 */
$response = Bot::setToken('seu token aqui')->sendMessage(
    chat_id: $chat_id,
    text: 'Test message'
);

var_dump($response);