emmaogunwobi/whatsapp-api
Composer 安装命令:
composer require emmaogunwobi/whatsapp-api
包简介
The whatsapp-notification package allows Laravel applications to send WhatsApp messages via Meta’s WhatsApp Cloud API. This package provides an easy-to-use service for sending template messages, handling API authentication, and managing message logging.
README 文档
README
📌 Introduction
whatsapp-api is a package that enables sending WhatsApp messages via Meta's WhatsApp Cloud API. It allows you to send text messages, template messages, and media (images, videos, documents) directly from your Laravel application.
https://developers.facebook.com/docs/whatsapp/cloud-api/get-started/
📦 Features
✅ Send WhatsApp text messages
✅ Send WhatsApp template messages
✅ Send media messages (images, videos, documents)
✅ Uses Meta's WhatsApp Cloud API
✅ Simple service-based architecture
✅ Easy configuration using .env
✅ Supports Laravel auto-discovery
📥 Installation
Install the Package via Composer
composer require yourvendor/whatsapp-notification
Publish the Configuration File
php artisan vendor:publish --tag=config
Add API Credentials to .env
WHATSAPP_ACCESS_TOKEN=your_facebook_whatsapp_api_access_token WHATSAPP_BUSINESS_PHONE_ID=your_whatsapp_business_phone_id
Usage
Use the WhatsAppService
Inject the WhatsAppService into your controller:
use Emmaogunwobi\WhatsAppApi\Services\WhatsAppService; class WhatsAppController extends Controller { protected $whatsappService; public function __construct(WhatsAppService $whatsappService) { $this->whatsappService = $whatsappService; } public function sendWhatsAppMessage() { $recipient = '2348123456789'; // WhatsApp number in international format $message = "Hello! This is a test message from Laravel."; $response = $this->whatsappService->sendMessage($recipient, $message); return response()->json($response); } }
Call the API
Start your Laravel app:
php artisan serve
Send a request
http://127.0.0.1:8000/api/send-whatsapp
Available Methods
Send a Custom Text Message
$response = $whatsappService->sendMessage('2348123456789', 'Hello from Laravel!');
2️⃣ Send a WhatsApp Template Message
$response = $whatsappService->sendTemplateMessage('2348123456789', 'hello_world');
3️⃣ Send a Media Message (Image, Video, Document)
$response = $whatsappService->sendMediaMessage('2348123456789', 'https://example.com/image.jpg', 'image');
emmaogunwobi/whatsapp-api 适用场景与选型建议
emmaogunwobi/whatsapp-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 emmaogunwobi/whatsapp-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 emmaogunwobi/whatsapp-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-01