digiworld/digichat-pure

Pure PHP client for DigiChat API

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/digiworld/digichat-pure

v1.0.0 2026-01-25 20:12 UTC

This package is auto-updated.

Last update: 2026-01-25 20:15:01 UTC


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