1. Go to this page and download the library: Download hoangkhacphuc/zalobot-sdk 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/ */
use ZaloBot\Sdk\ZaloBot;
use ZaloBot\Sdk\ZaloClient;
// Any PSR-18 ClientInterface implementation works.
$myClient = new MyCustomHttpClient();
$bot = new ZaloBot([
'botToken' => $_ENV['ZALO_BOT_TOKEN'],
'secretKey' => $_ENV['ZALO_BOT_SECRET'] ?? null,
], $myClient);
// Or use ZaloClient directly for lower-level control:
$client = new ZaloClient($_ENV['ZALO_BOT_TOKEN'], httpClient: $myClient);
$result = $client->get('getMe');
// Streams to a temp file, then atomically renames into place.
// Redirects are rejected — download URLs are validated against SSRF rules.
$bot->media->downloadMedia('attachment_id', '/tmp/save/image.png');