mdestafadilah/restapiwa 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mdestafadilah/restapiwa

Composer 安装命令:

composer require mdestafadilah/restapiwa

包简介

REST API For Whatsapp Defined!

README 文档

README

Ini Hanya REST API WhatsApp Client sederhana yang saya buat untuk keperluan pribadi, jika ada yang mau menggunakan silahkan, tapi jangan lupa untuk menghargai karya orang lain.

Pre-Required (Before Use This simple Library)

Pastikan sudah menjalankan service whatsapp berikut:

  1. https://github.com/andresayac/baileys-api
  2. https://github.com/wppconnect-team/wppconnect-server
  3. https://github.com/mimamch/wa-gateway
  4. https://github.com/avoylenko/wwebjs-api
  5. https://github.com/asternic/wuzapi
  6. https://github.com/LuizFelipeNeves/go-whatsapp-web-multidevice
  7. https://github.com/EvolutionAPI/evolution-api
  8. https://github.com/farinchan/chatery_whatsapp

Please, make sure you already running 8 backend services above.

Installation

composer require mdestafadilah/restapiwa

Features

  • ✅ Multiple backend support (Backend 3, 4, 7, 8, and 99)
  • ✅ Automatic backend selection with health check
  • ✅ Phone number normalization
  • ✅ Group message support
  • ✅ Custom logging
  • ✅ Error handling with Guzzle exceptions
  • ✅ Configurable message footer
  • SQLite database for server configuration management
  • Automatic message logging to database
  • Admin web interface for server management

Quick Start

With Database (Recommended)

<?php

require 'vendor/autoload.php';

use Mdestafadilah\ApiWaRest\WhatsAppGateway;
use Mdestafadilah\ApiWaRest\DatabaseManager;

// Initialize database
$db = new DatabaseManager(__DIR__ . '/data/wa_gateway.db');
$db->init();

// Initialize WhatsApp Gateway with database
$wa = new WhatsAppGateway([], null, $db);

// Send message - configuration loaded from database automatically
$response = $wa->sendMessage([
    'nomorhp' => '081234567890',
    'pesanwa' => 'Hello from WhatsApp Gateway!'
], 3);

With Array Configuration (Traditional)

<?php

require 'vendor/autoload.php';

use Mdestafadilah\ApiWaRest\WhatsAppGateway;

$config = [
    'footer' => "\n\n--\nPowered by WhatsApp Gateway",
    'servers' => [
        3 => [
            'base_url' => 'https://v3.apiwa.persahabatan.co.id',
            'session_id' => 'your-session-id',
            'token' => ''
        ],
        4 => [
            'base_url' => 'https://v4.apiwa.persahabatan.co.id/',
            'token' => 'your-token'
        ]
    ]
];

$wa = new WhatsAppGateway($config);
$response = $wa->sendMessage(['nomorhp' => '081234567890', 'pesanwa' => 'Hello!'], 3);

Database Management

Admin Web Interface

Access the admin interface to manage server configurations:

  1. Open admin/index.php in your browser
  2. Add, edit, or delete server configurations
  3. Toggle servers active/inactive
  4. View all configured backends

Programmatic Server Management

use Mdestafadilah\ApiWaRest\DatabaseManager;

$db = new DatabaseManager(__DIR__ . '/data/wa_gateway.db');
$db->init();

// Add a server
$serverId = $db->create([
    'backend_id' => 3,
    'name' => 'Production Server',
    'base_url' => 'https://v3.apiwa.persahabatan.co.id',
    'session_id' => 'your-session-id',
    'token' => '',
    'phone' => '628123456789',
    'is_active' => 1
]);

// Get all servers
$servers = $db->getAll();

// Get active servers only
$activeServers = $db->getActiveServers();

// Update server
$db->update($serverId, ['name' => 'Updated Name', 'is_active' => 0]);

// Delete server
$db->delete($serverId);

Message Logging

All messages are automatically logged to the database when using DatabaseManager:

// Get recent logs
$logs = $db->getMessageLogs(50); // Get last 50 messages

// Get logs by phone number
$logs = $db->getMessageLogsByNumber('628123456789', 20);

// Get log by unique ID
$log = $db->getMessageLogByUniqueId('ORDER-2024-001');

Usage Examples

Send to Group

$response = $wa->sendMessage([
    'nomorhp' => '120363xxxxxxxxxx@g.us',
    'pesanwa' => 'Hello group!'
], 3, true); // isGroup = true

Automatic Backend Selection

$response = $wa->sendMessage([
    'nomorhp' => '081234567890',
    'pesanwa' => 'Auto backend!'
], 3, false, true); // otomatis = true

With Custom Logger

$wa->setLogger(function($logData) {
    file_put_contents('wa-log.txt', json_encode($logData) . "\n", FILE_APPEND);
});

With Custom Unique ID

$response = $wa->sendMessage([
    'nomorhp' => '081234567890',
    'pesanwa' => 'Order confirmation'
], 3, false, false, 'ORDER-2024-001');

Backend Services

Backend 3

  • Free service
  • Requires: base_url, session_id
  • Supports: Individual & Group messages

Backend 4

  • Free service
  • Requires: base_url, token
  • Supports: Individual & Group messages

Backend 7

  • Free service
  • Requires: base_url, token
  • Supports: Individual & Group messages

Backend 8

  • Free service
  • Requires: base_url, session_id, token
  • Supports: Individual & Group messages

Backend 99

  • Premium OTP service (Paid)
  • Requires: base_url, userkey, passkey
  • Supports: Individual messages only

Database Schema

wa_servers table

  • id - Auto increment primary key
  • backend_id - Backend ID (3, 4, 8, 99)
  • name - Server name/description
  • base_url - API base URL
  • token - API token
  • session_id - Session ID (for backends 3 & 8)
  • phone - Phone number
  • userkey - User key (for backend 99)
  • passkey - Pass key (for backend 99)
  • is_active - Active status (1 or 0)
  • created_at - Creation timestamp
  • updated_at - Last update timestamp

wa_message_logs table

  • id - Auto increment primary key
  • number - Recipient phone number
  • message - Message content
  • payload - JSON payload sent to backend
  • id_unik - Unique identifier
  • status - Message status
  • created_at - Timestamp

Requirements

  • PHP 7.4 or higher
  • PDO SQLite extension
  • Guzzle HTTP Client ^7.9

License

MIT License

Author

mdestafadilah
Email: desta.08b@gmail.com

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

mdestafadilah/restapiwa 适用场景与选型建议

mdestafadilah/restapiwa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mdestafadilah/restapiwa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mdestafadilah/restapiwa 我们能提供哪些服务?
定制开发 / 二次开发

基于 mdestafadilah/restapiwa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05