emmaogunwobi/whatsapp-api 问题修复 & 功能扩展

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

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

emmaogunwobi/whatsapp-api

最新稳定版本:v1.0.1

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');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-01