octopusteam/waapi-laravel
Composer 安装命令:
composer require octopusteam/waapi-laravel
包简介
WAAPI whatsapp api integration for Laravel
README 文档
README
This package provides a simple and expressive API for interacting with the WAAPI (WhatsApp API) service within a Laravel application.
Features
- Send text messages, media, templates, stickers, voice notes, locations, and contacts.
- New Send conversation messages and check contact presence.
- New Manage Devices and Apps (Create, Read, Update, Delete).
- New Check messages status and fetch profile pictures in batch.
- Fluent and expressive API.
- Automatic webhook route registration.
- New
WebhookReceivedevent for incoming data. - Integration with Webhook.site for easy debugging.
- Artisan command to renew Webhook.site token.
Installation
composer require octopusteam/waapi-laravel
Publish the configuration file:
php artisan vendor:publish --provider="OctopusTeam\Waapi\WaapiServiceProvider"
This will create a config/waapi.php file in your application.
Configuration
Update your .env file with your WAAPI credentials:
WAAPI_APP_URL=https://waapi.octopusteam.net/api/create-message
WAAPI_APP_KEY=your_app_key
WAAPI_AUTH_KEY=your_auth_key
WAAPI_WEBHOOK_SITE_TOKEN=your_webhook_site_token
WAAPI_UPDATE_DEVICE_WEBHOOK=your_device_uuid_for_webhook_update
Usage
Sending Messages
You can send messages using the Waapi facade or by injecting the Waapi class.
use OctopusTeam\Waapi\Facades\Waapi; // Send a simple text message Waapi::sendMessage('201xxxxxxxxx', 'Hello, world!'); // Send an OTP with custom message $otp = Waapi::generateOtp(); Waapi::sendOtp('201xxxxxxxxx', $otp, false, false, ":otp is your verification code."); // Send Media (File) Waapi::sendMedia('201xxxxxxxxx', 'Here is your invoice', 'https://example.com/invoice.pdf'); // Send Template Waapi::sendTemplate('201xxxxxxxxx', 'template_id', [ 'variables[{1}]' => 'Value 1', 'variables[{2}]' => 'Value 2' ]); // Send Sticker Waapi::sendSticker('201xxxxxxxxx', 'https://example.com/sticker.webp'); // Send Voice Note Waapi::sendVoice('201xxxxxxxxx', 'https://example.com/voice.mp3'); // Send Location Waapi::sendLocation('201xxxxxxxxx', '30.0444', '31.2357'); // Send Contact Waapi::sendContact('201xxxxxxxxx', 'John Doe', '201xxxxxxxxx', 'Octopus Team'); // Send Conversation Message Waapi::sendConversationMessage('201xxxxxxxxx', 'Hello from conversation');
Device Status & QR Code
// Get Device Status $status = Waapi::getDeviceStatus('device_id'); // Get QR Code $qr = Waapi::getQrCode('device_id');
Message Status
// Get single message status $status = Waapi::getMessageStatus('message_id'); // Get multiple messages status $status = Waapi::getMessagesStatus(['id1', 'id2', 'id3']);
Devices Management
// Get all devices $devices = Waapi::getDevices(); // Create a new device $device = Waapi::createDevice('New Device Name', 'https://webhook.site/...'); // Get a specific device $device = Waapi::getDevice('device_id'); // Update a device $updated = Waapi::updateDevice('device_id', 'Updated Name', 'https://webhook.site/...'); // Delete a device $deleted = Waapi::deleteDevice('device_id');
Apps Management
// Get all apps $apps = Waapi::getApps(); // Create a new app $app = Waapi::createApp('App Name', 'device_id', 'https://example.com'); // Get a specific app $app = Waapi::getApp('app_id'); // Delete an app $deleted = Waapi::deleteApp('app_id');
Profile & Presence
// Check contact presence on WhatsApp $presence = Waapi::contactPresence('device_id', '201xxxxxxxxx'); // Get Profile Pictures (batch) $pictures = Waapi::getProfilePictures(['201xxxxxxxxx', '201yyyyyyyyy'], 'device_id');
Webhook Settings API
// Get current webhook settings $settings = Waapi::getWebhookSettings(); // Update webhook settings $updated = Waapi::updateWebhookSettings('https://example.com/webhook');
Webhook Handling
The package can automatically register a webhook route to handle incoming data from WAAPI. To enable this, ensure the following is in your config/waapi.php:
'webhook' => [ 'enabled' => true, 'auto_register' => true, ],
By default, the route is POST /api/webhook/whatsapp.
Events
When a webhook is received, the package fires the OctopusTeam\Waapi\Events\WebhookReceived event. You can listen to this event in your application's EventServiceProvider.
use OctopusTeam\Waapi\Events\WebhookReceived; protected $listen = [ WebhookReceived::class => [ SendEmailNotification::class, ], ];
The event contains the webhook data in the $data property.
Webhook.site Integration
For development and debugging, you can use the Webhook.site integration to inspect incoming webhook data.
// Get the last 50 requests from Webhook.site $data = Waapi::getWebhookSiteData(50); // Get the decoded content from the last 50 requests $content = Waapi::getWebhookSiteContent(50); // Get a specific request by its ID $request = Waapi::getWebhookSiteRequest('request-uuid');
Artisan Command
To renew your webhook.site token automatically, you can run the following Artisan command. This will generate a new token, update your .env file, and update the webhook URL via the WAAPI service.
php artisan waapi:webhook-renew
octopusteam/waapi-laravel 适用场景与选型建议
octopusteam/waapi-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 236 次下载、GitHub Stars 达 15, 最近一次更新时间为 2025 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「laravel」 「whatsapp」 「WaAPI」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 octopusteam/waapi-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 octopusteam/waapi-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 octopusteam/waapi-laravel 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 236
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-18