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

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

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

caydeesoft/whatsapp

Composer 安装命令:

composer require caydeesoft/whatsapp

包简介

A robust Laravel package for integrating with the Meta WhatsApp Cloud API, supporting messaging, webhooks, and media handling.

README 文档

README

Direct Meta WhatsApp Cloud API integration for Laravel.

Features

  • Webhook verification endpoint
  • Inbound webhook handler
  • Outbound text message endpoint
  • Outbound template message endpoint
  • HMAC validation with X-Hub-Signature-256
  • Event dispatching for inbound webhook payloads
  • Publishable config file

Package Structure

  • src/WhatsAppServiceProvider.php: package bootstrapping
  • src/Services/MetaWhatsAppClient.php: direct Meta Graph API client
  • src/Http/Controllers/WhatsAppWebhookController.php: webhook verification and inbound handling
  • src/Http/Controllers/WhatsAppMessageController.php: outbound message endpoints
  • src/Events/WhatsAppWebhookReceived.php: event fired for inbound webhook payloads
  • config/whatsapp.php: package configuration
  • routes/api.php: package routes

Configuration

Environment variables used by the package:

WHATSAPP_BASE_URL=https://graph.facebook.com
WHATSAPP_GRAPH_VERSION=v24.0
WHATSAPP_ACCESS_TOKEN=
WHATSAPP_PHONE_NUMBER_ID=
WHATSAPP_BUSINESS_ACCOUNT_ID=
WHATSAPP_APP_SECRET=
WHATSAPP_WEBHOOK_VERIFY_TOKEN=
WHATSAPP_ROUTE_PREFIX=whatsapp

You can publish the config into the host Laravel app with:

php artisan vendor:publish --tag=whatsapp-config

Published config path:

config/whatsapp.php

Routes

By default the package exposes these routes:

  • GET /api/whatsapp/webhook
  • POST /api/whatsapp/webhook
  • POST /api/whatsapp/messages/text
  • POST /api/whatsapp/messages/template

The whatsapp segment is configurable through WHATSAPP_ROUTE_PREFIX.

Usage

Verify webhook

Meta will call:

GET /api/whatsapp/webhook?hub.mode=subscribe&hub.verify_token=...&hub.challenge=...

The package validates the verify token and returns the challenge string.

Receive inbound webhooks

Meta will send webhook payloads to:

POST /api/whatsapp/webhook

If WHATSAPP_APP_SECRET is configured, the package validates the X-Hub-Signature-256 signature before accepting the request.

The package then dispatches:

SocialMedia\WhatsApp\Events\WhatsAppWebhookReceived

Send a text message

Request:

POST /api/whatsapp/messages/text
{
  "to": "254700000000",
  "body": "Hello from Laravel"
}

Send a template message

Request:

POST /api/whatsapp/messages/template
{
  "to": "254700000000",
  "name": "hello_world",
  "language": "en_US"
}

Extending in the Host App

Listen for the webhook event in your app to process messages, statuses, and delivery updates:

use SocialMedia\WhatsApp\Events\WhatsAppWebhookReceived;

Event::listen(WhatsAppWebhookReceived::class, function (WhatsAppWebhookReceived $event) {
    // Handle $event->payload
});

Meta Setup Checklist

  1. Create a Meta app and enable the WhatsApp product.
  2. Get an access token.
  3. Get your Phone Number ID and WhatsApp Business Account ID.
  4. Set the Meta webhook callback URL to your app's /api/whatsapp/webhook endpoint.
  5. Set Meta's verify token to match WHATSAPP_WEBHOOK_VERIFY_TOKEN.
  6. Subscribe the app to your WABA.

References

caydeesoft/whatsapp 适用场景与选型建议

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

它主要适用于以下技术方向: 「messaging」 「laravel」 「meta」 「whatsapp」 「webhooks」 「cloud api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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