zaptilo/whatsapp 问题修复 & 功能扩展

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

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

zaptilo/whatsapp

Composer 安装命令:

composer require zaptilo/whatsapp

包简介

Zaptilo WhatsApp Business API SDK for PHP — Send text, media, and template messages via WhatsApp.

README 文档

README

Official PHP SDK for the Zaptilo WhatsApp Business API. Send text, media, and template messages via WhatsApp with a simple, clean API.

Installation

composer require zaptilo/whatsapp

Requirements: PHP 7.4+, cURL extension, JSON extension

Quick Start

use Zaptilo\WhatsApp\Zaptilo;

$zaptilo = new Zaptilo('YOUR_API_TOKEN');

// Send a text message
$response = $zaptilo->sendMessage('919876543210', 'Hello from Zaptilo!');

Get your API token from the Zaptilo Dashboard under Developer Tools > Access Tokens.

Usage

Send Text Message

$zaptilo->sendMessage('919876543210', 'Hello! Your order has been confirmed.');

Send Template Message

$zaptilo->sendTemplate(
    '919876543210',        // Phone number
    'order_update',        // Template name
    'en',                  // Language
    ['John', 'Shipped'],   // Body parameter values
    ['#ORD-1234']          // Header parameter values (optional)
);

Send Media Message

// Send image
$zaptilo->sendMedia('919876543210', 'https://example.com/photo.jpg', 'image', 'Check this out!');

// Send document
$zaptilo->sendMedia('919876543210', 'https://example.com/invoice.pdf', 'document', 'Your invoice');

// Send video
$zaptilo->sendMedia('919876543210', 'https://example.com/video.mp4', 'video');

List Templates

$templates = $zaptilo->getTemplates();

foreach ($templates['data'] as $template) {
    echo $template['name'] . ' - ' . $template['status'] . PHP_EOL;
}

Check Credit Balance

$result = $zaptilo->getBalance();
echo 'Balance: ' . $result['balance'];

Verify API Token

$result = $zaptilo->verify();
echo $result['message']; // "API key is valid and active"

Error Handling

use Zaptilo\WhatsApp\Zaptilo;
use Zaptilo\WhatsApp\ZaptiloException;

$zaptilo = new Zaptilo('YOUR_API_TOKEN');

try {
    $zaptilo->sendMessage('919876543210', 'Hello!');
} catch (ZaptiloException $e) {
    echo 'Error: ' . $e->getMessage();
    echo 'Code: ' . $e->getCode();
}

Configuration

// Custom base URL (for self-hosted or staging)
$zaptilo = new Zaptilo('YOUR_TOKEN', 'https://your-domain.com');

// Custom timeout (default: 30 seconds)
$zaptilo = new Zaptilo('YOUR_TOKEN', 'https://zaptilo.ai', 60);

API Reference

Method Description
sendMessage($number, $message) Send a text message
sendMedia($number, $mediaUrl, $mediaType, $caption) Send image, video, or document
sendTemplate($number, $templateName, $language, $bodyValues, $headerValues) Send a template message
getTemplates() List all approved templates
getBalance() Get current credit balance
verify() Verify API token and subscription status

Laravel Integration

Add your token to .env:

ZAPTILO_API_TOKEN=your_token_here

Create a service provider or use it directly:

use Zaptilo\WhatsApp\Zaptilo;

$zaptilo = new Zaptilo(env('ZAPTILO_API_TOKEN'));
$zaptilo->sendMessage('919876543210', 'Hello from Laravel!');

Links

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固