Download the PHP package hoangkhacphuc/zalobot-sdk without Composer
On this page you can find all versions of the php package hoangkhacphuc/zalobot-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hoangkhacphuc/zalobot-sdk
More information about hoangkhacphuc/zalobot-sdk
Files in hoangkhacphuc/zalobot-sdk
Package zalobot-sdk
Short Description A lightweight, modular PHP SDK and Webhook handler for Zalo Bot Platform API (bot.zapps.me). Fully typed with PHPDoc and ready for production.
License MIT
Homepage https://github.com/NightOwl-VN/zalo_bot_php
Informations about the package zalobot-sdk
ZaloBot SDK for PHP
Lightweight, modular PHP SDK for the Zalo Bot Platform API. Zero framework coupling, PSR-18 HTTP client support, strict types (PHP 8.1+).
Port of the Node.js zalobot-sdk.
Installation
Requirements
- PHP >= 8.1
- PSR-18 HTTP Client (
guzzlehttp/guzzle^7.0 || ^8.0 is included as default)
Quick Start
Custom PSR-18 Client
Inject your own PSR-18 client — no Guzzle dependency required on your side:
Sending Messages
Webhook Handling
User Profile (with Cache)
Media Upload
Media Download
Error Handling
All SDK exceptions extend ZaloBotException:
| Exception | When |
|---|---|
ApiException |
API error response or malformed JSON from server |
AuthException |
Invalid or expired bot token (HTTP 401/403) |
RateLimitException |
HTTP 429 — use $e->getRetryAfter() for backoff seconds |
WebhookException |
Webhook secret mismatch |
ValidationException |
Input validation failure or SSRF URL rejection |
NetworkException |
Connection failure (DNS, TLS, transport — from PSR-18 client) |
TimeoutException |
Request timeout (detected via Guzzle context, not message parsing) |
Programming errors (
TypeError,Error,LogicException,InvalidArgumentException) are never caught and masked — they propagate unchanged so bugs surface immediately.
Retry Policy
Automatic retry is read-only safe by default: only GET requests are retried.
POST / PUT / upload requests are never auto-retried unless you opt in.
| Status | Retried? |
|---|---|
| 408, 429, 502, 503, 504 | ✅ yes (GET only by default) |
| Network connection failure | ✅ yes (GET only, transient — not a timeout) |
| 400, 401, 403, 404, 422 | ❌ never |
| Timeout | ❌ never |
To opt in to mutating-request retries (only if your operations are idempotent):
Backoff uses exponential delay with jitter and respects the Retry-After header
(seconds or HTTP-date format). Guzzle timeouts are detected via handler context
(errno 28 / timed_out) and mapped to TimeoutException — not retried.
Download Redirect Policy
MediaModule::downloadMedia() does not follow HTTP redirects. A 3xx response
is treated as a failure because the redirect target may be a private host that
bypassed the initial SSRF validation.
Environment Variables
| Variable | Default | Description |
|---|---|---|
ZALO_BOT_TOKEN |
required | Bot token from bot.zapps.me |
ZALO_BOT_SECRET |
null |
Webhook secret (8–256 chars) |
ZALO_BOT_TIMEOUT |
30000 |
Request timeout in milliseconds |
ZALO_BOT_MAX_RETRIES |
3 |
Max retry attempts for 429 / transient errors |
ZALO_BOT_BASE_URL |
https://bot-api.zaloplatforms.com |
API base URL |
Development
License
MIT — see LICENSE for details.
All versions of zalobot-sdk with dependencies
psr/http-client Version ^1.0
psr/http-message Version ^2.0
guzzlehttp/guzzle Version ^7.0 || ^8.0