PHP code example of webtolk / max

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

    

webtolk / max example snippets




declare(strict_types=1);

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use Webtolk\Max\Config\MaxConfig;
use Webtolk\Max\Max;

alse,
        'timeout' => 20,
        'connect_timeout' => 8,
    ]),
    $factory,
    $factory,
);

$bot = $max->bots()->me();

echo 'Bot ID: ' . $bot->getId() . PHP_EOL;
echo 'Username: ' . $bot->getUsername() . PHP_EOL;

use Webtolk\Max\Payload\NewMessageBody;

$message = $max->messages()->sendToChat(
    123456,
    NewMessageBody::text('Привет из MAX SDK'),
);

echo $message->getBody()?->getText() ?? '';