PHP code example of bootdesk / chat-sdk-adapter-telegram
1. Go to this page and download the library: Download bootdesk/chat-sdk-adapter-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/ */
bootdesk / chat-sdk-adapter-telegram example snippets
use BootDesk\ChatSDK\Telegram\TelegramAdapter;
$adapter = new TelegramAdapter(
botToken: env('TELEGRAM_BOT_TOKEN'),
httpClient: new \GuzzleHttp\Client,
secretToken: env('TELEGRAM_SECRET_TOKEN'),
);
// Post a message to a chat
$adapter->postMessage('telegram:123456789', 'Hello from laravel-bootdesk!');
// Post in a topic forum
$adapter->postMessage('telegram:-100123456789:42', 'Topic message');
use BootDesk\ChatSDK\Core\PostableMessage;
use BootDesk\ChatSDK\Telegram\Keyboard\KeyboardButton;
use BootDesk\ChatSDK\Telegram\Keyboard\ReplyKeyboardMarkup;
// Custom reply keyboard with location request
$thread->post(new PostableMessage(
content: 'Choose an option:',
metadata: [
'reply_markup' => new ReplyKeyboardMarkup(
keyboard: [
[new KeyboardButton('Help')],
[new KeyboardButton('Share Location', requestLocation: true)],
[new KeyboardButton('Share Contact', requestContact: true)],
],
resizeKeyboard: true,
oneTimeKeyboard: true,
),
],
));
$thread->post(new PostableMessage(
content: 'Reply to this',
replyToMessageId: '42',
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.