digiworld/digichat
Composer 安装命令:
composer require digiworld/digichat
包简介
Laravel package for DigiChat WhatsApp API integration
README 文档
README
DigiChat
DigiChat is a lightweight Laravel package that lets your app send WhatsApp messages and manage the session through DigiChat.
✅ Requirements
- PHP 8.2+
- Laravel 8 / 9 / 10 / 11 / 12 / 13
📦 Installation
Install via Composer:
composer require digiworld/digichat
Then publish the config:
php artisan digichat:install
⚙️ Configuration
Add the following to your .env:
DIGICHAT_API_TOKEN=your_token_here DIGICHAT_API_SECRET=your_secret_here
You can find these credentials in your DigiChat dashboard:
https://chat.digiworld-dev.com/
If you don’t have access, please contact DigiWorld support.
Full docs are available here:
https://digichat.digiworld-dev.com/docs
🚀 Quick Start
Using the Facade:
use Digiworld\DigiChat\Facades\DigiChat; $response = DigiChat::sendMessage('963XXXXXXXX', 'Hello from DigiChat');
Using the Manager directly:
use Digiworld\DigiChat\DigiChatManager; Route::get('/digichat/test', function (DigiChatManager $digichat) { return $digichat->sendMessage('963XXXXXXXX', 'Hello from DigiChat'); });
🔀 Multi Session
The package config acts as the default session.
If you need multiple DigiChat sessions in the same Laravel project, use either the facade session() helper or create a manager with credentials directly.
Using the Facade session helper:
use Digiworld\DigiChat\Facades\DigiChat; $sessionA = DigiChat::session('token-a', 'secret-a'); $sessionB = DigiChat::session('token-b', 'secret-b'); $sessionA->sendText('123456789@g.us', 'Message from session A'); $sessionB->sendText('987654321@g.us', 'Message from session B');
Using the Manager constructor:
use Digiworld\DigiChat\DigiChatManager; $client = new DigiChatManager('token-a', 'secret-a'); $client->sendText('123456789@g.us', 'Message from custom client');
Using the Laravel container with runtime credentials:
$client = app(\Digiworld\DigiChat\DigiChatManager::class, [ 'token' => 'token-a', 'secret' => 'secret-a', ]);
If token or secret is null, the package falls back to the values from config/digichat.php.
💬 Chat ID Formats
- Contact:
963XXXXXXXXor963XXXXXXXX@c.us - Group:
123456789@g.us - Newsletter / Channel:
123456789@newsletter
Notes:
- Contact numbers starting with
+are normalized automatically. sendMessage()is still available for plain contact text messages.sendText()supports contacts, groups, and newsletters.sendMedia()supports contacts, groups, and newsletters.sendFile()supports contacts and groups only.- Newsletter / channel file sends are not supported.
📚 Available Methods
1) session(?string $token = null, ?string $secret = null): DigiChatManager
Create an isolated client for another DigiChat session.
$otherSession = DigiChat::session('token-a', 'secret-a'); $otherSession->sendText('123456789@g.us', 'Hello from another session');
2) sendMessage(string $phoneNumber, string $message): array
Send a plain text message to a contact.
DigiChat::sendMessage('963XXXXXXXX', 'Hello there');
3) send(array $payload): array
Send a prepared payload.
DigiChat::send([ 'chatId' => '963XXXXXXXX', 'type' => 'text', 'text' => 'Hello from send()', ]);
4) sendText(string $chatId, string $text, array $options = []): array
Send text to a contact, group, or newsletter.
DigiChat::sendText('963XXXXXXXX', 'Hello contact'); DigiChat::sendText('123456789@g.us', 'Hello group'); DigiChat::sendText('123456789@newsletter', 'Latest update');
5) sendMedia(string $chatId, array|string $media, ?string $caption = null, array $options = []): array
Send media with an optional caption.
DigiChat::sendMedia('123456789@g.us', [ 'mimetype' => 'image/png', 'filename' => 'image.png', 'base64' => base64_encode(file_get_contents(storage_path('app/image.png'))), ], 'Image caption'); DigiChat::sendMedia('123456789@newsletter', [ 'mimetype' => 'image/jpeg', 'filename' => 'update.jpg', 'base64' => base64_encode(file_get_contents(storage_path('app/update.jpg'))), ], 'Channel update');
6) sendFile(string $chatId, array|string $media, ?string $caption = null, array $options = []): array
Send a file to a contact or group.
DigiChat::sendFile('123456789@g.us', [ 'mimetype' => 'application/pdf', 'filename' => 'report.pdf', 'base64' => base64_encode(file_get_contents(storage_path('app/report.pdf'))), ], 'Monthly report');
7) getQr(): array
Get the current QR payload for session pairing.
$qr = DigiChat::getQr();
8) getStatus(): array
Get the current session status.
$status = DigiChat::getStatus();
9) start(): array
Start the session.
$start = DigiChat::start();
10) refresh(bool $withDeletion = false): array
Refresh the session.
$refresh = DigiChat::refresh(); $refreshAndDelete = DigiChat::refresh(withDeletion: true);
11) logout(bool $withDeletion = false): array
Logout the current session.
$logout = DigiChat::logout(); $logoutAndDelete = DigiChat::logout(withDeletion: true);
12) ping(): array
Check API availability.
$ping = DigiChat::ping();
13) getInviteInfo(string $inviteCode): array
Get WhatsApp invite information.
$invite = DigiChat::getInviteInfo('YOUR_INVITE_CODE');
14) getChannelInfo(array|string $invite): array
Get newsletter / channel information from an invite code or invite link.
$channelByCode = DigiChat::getChannelInfo('AbCdEfGhIjK'); $channelByLink = DigiChat::getChannelInfo('https://whatsapp.com/channel/AbCdEfGhIjK');
🛠 Example Route
use Illuminate\Support\Facades\Route; use Digiworld\DigiChat\Facades\DigiChat; Route::get('/digichat/demo', function () { return response()->json([ 'send' => DigiChat::sendMessage('963XXXXXXXX', 'Hello from DigiChat'), 'status' => DigiChat::getStatus(), ]); });
📝 Notes
- All methods return the API response as an array.
- Config credentials act as the default session.
- Use
session()ornew DigiChatManager($token, $secret)for multi-session usage. - Existing
sendMessage()integrations remain supported. - New projects can use
sendText(),sendMedia(),sendFile(), orsend(). getChannelInfo()can resolve channel details from either a code or a full WhatsApp channel invite link.
🛑 Disclaimer
Important Notice: DigiChat uses unofficial access to WhatsApp, which may violate WhatsApp’s Terms of Service.
By using this package, you acknowledge that:
- Your phone number may be banned by WhatsApp for using unofficial APIs.
- DigiWorld is not responsible for any bans, suspensions, or loss of access to your WhatsApp account.
- Use this tool at your own risk and only for permitted purposes.
💬 Support
- Dashboard: https://chat.digiworld-dev.com/
- Docs: https://digichat.digiworld-dev.com/docs
- Email: support@digiworld-dev.com
digiworld/digichat 适用场景与选型建议
digiworld/digichat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「laravel」 「whatsapp」 「digichat」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 digiworld/digichat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 digiworld/digichat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 digiworld/digichat 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
WhatsApp Latest CLoud API Wrapper for PHP
Alfabank REST API integration
The PHP WhatsApp library
Cliente Wis SDK para PHP
fuel price monitor provides a web dashboard and a configurable update notifier
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-17