承接 digiworld/digichat-pure 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digiworld/digichat-pure

最新稳定版本:v1.0.0

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-curl
    • ext-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 $success
  • public readonly ?string $message
  • public 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)

  1. Install dev deps:
composer install
  1. Create .env at package root:
DIGICHAT_TOKEN=YOUR_TOKEN
DIGICHAT_SECRET=YOUR_SECRET
  1. 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/ping
  • GET http://127.0.0.1:8000/api/status
  • POST http://127.0.0.1:8000/api/send-message

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固