PHP code example of slatch / telegram-bot-client

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

    

slatch / telegram-bot-client example snippets


use Slatch\TelegramBotClient\Api\Config;
use Slatch\TelegramBotClient\Arguments\SendMessage;
use Slatch\TelegramBotClient\BotClient;
use Slatch\TelegramBotClient\Bot\Credentials;

...

// Initialize bot client
$botClient = new BotClient($httpClient, new Credentials($token), new Config('https://api.telegram.org'));

// Prepare message
$message = new SendMessage();
$message->setChatId(12345678);
$message->setText("Hello World!");

// Send
$botClient->sendMessage($message);