digiworld/digichat-pure
Composer 安装命令:
composer require digiworld/digichat-pure
包简介
Pure PHP client for DigiChat API
README 文档
README
Pure PHP (framework-agnostic) client for the DigiChat WhatsApp platform API.
- ✅ No Laravel / no framework dependencies
- ✅ Uses cURL (no Guzzle)
- ✅ Typed response objects (DTO-style)
- ✅ Suitable for CLI scripts, cron jobs, and any PHP app
Install:
composer require digiworld/digichat-pure
Platform
DigiChat Platform: https://digichat.digiworld-dev.com
Requirements
- PHP 8.1+
- PHP extensions:
ext-curlext-json
Installation
composer require digiworld/digichat-pure
Quick Start
<?php require __DIR__ . '/vendor/autoload.php'; use Digiworld\DigiChat\DigiChatClient; $token = 'YOUR_TOKEN'; $secret = 'YOUR_SECRET'; $client = new DigiChatClient($token, $secret); // Ping $ping = $client->ping(); var_dump($ping->success, $ping->message); // Status $status = $client->getStatus(); echo "Status: " . ($status->status ?? 'UNKNOWN') . PHP_EOL; // Send a message $send = $client->sendMessage('+31600000000', 'Hello from digichat-pure'); var_dump($send->success, $send->messageId, $send->status);
Usage
1) ping()
$res = $client->ping(); if ($res->success) { echo $res->message . PHP_EOL; // e.g. "pong" }
Returns: OperationResponse
2) getStatus()
$res = $client->getStatus(); echo $res->status . PHP_EOL; // e.g. READY / OFFLINE / ... echo $res->progressPercent . PHP_EOL; // optional, if API returns progress
Returns: StatusResponse
3) getQr()
$res = $client->getQr(); echo $res->qr . PHP_EOL; // QR text (if provided by API) echo $res->imageBase64 . PHP_EOL; // Base64 QR image (if provided by API)
Returns: QrResponse
4) sendMessage($phone, $message, $options = [])
// phone number MUST not start with leading 0 or + $res = $client->sendMessage('963900000000', 'Hello!'); echo $res. PHP_EOL;
Returns: SendMessageResponse
5) start()
$res = $client->start(); echo $res->message . PHP_EOL;
Returns: OperationResponse
6) refresh($withDeletion = false)
$res = $client->refresh(false); echo $res->message . PHP_EOL;
Returns: OperationResponse
7) logout($withDeletion = false)
$res = $client->logout(false); echo $res->message . PHP_EOL;
Returns: OperationResponse
8) getInviteInfo($inviteCode)
$res = $client->getInviteInfo('INV-123'); var_dump( $res->inviteCode, $res->valid ); // Raw info payload (if present) var_dump($res->info);
Returns: InviteInfoResponse
Responses (Typed DTOs)
All response objects extend BaseResponse and expose:
public readonly ?bool $successpublic readonly ?string $messagepublic readonly array $raw(full raw response payload)
Example:
$res = $client->getStatus(); if ($res->success !== true) { // $res->raw has the full API payload for debugging var_dump($res->message, $res->raw); }
Error Handling
The client throws DigiChatException for HTTP/network errors and non-2xx responses.
use Digiworld\DigiChat\Exceptions\DigiChatException; try { $res = $client->sendMessage('963900000000', 'Hello'); } catch (DigiChatException $e) { echo $e->getMessage() . PHP_EOL; // if your exception stores details, dump them: // var_dump($e->getCode(), $e->details ?? null); }
Base URL
The base URL is hardcoded inside the client (not user-configurable) by design.
Development
Local wrapper server (optional)
- Install dev deps:
composer install
- Create
.envat package root:
DIGICHAT_TOKEN=YOUR_TOKEN DIGICHAT_SECRET=YOUR_SECRET
- Run:
php -S 127.0.0.1:8000 -t dev-server/public
Then test endpoints (Postman/curl):
GET http://127.0.0.1:8000/api/pingGET http://127.0.0.1:8000/api/statusPOST http://127.0.0.1:8000/api/send-message
License
MIT
digiworld/digichat-pure 适用场景与选型建议
digiworld/digichat-pure 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 digiworld/digichat-pure 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 digiworld/digichat-pure 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-25