承接 ahmedtaha-dev/whatsapp-bevatel-provider 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ahmedtaha-dev/whatsapp-bevatel-provider

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ahmedtaha-dev/whatsapp-bevatel-provider

包简介

A package for integrating with Bevatel WhatsApp API

README 文档

README

PHP helpers for sending template messages through the Bevatel WhatsApp API from Laravel (or any app using Laravel’s HTTP client and config).

Requirements

  • PHP ^8.1
  • Laravel ^9^12 (package depends on illuminate/support and illuminate/http)

Installation

composer require ahmedtaha-dev/whatsapp-bevatel-provider

Configuration

Environment variables

Set these in .env (or your runtime):

Variable Description
BEVATEL_ACCOUNT_ID Account identifier sent as api_account_id
BEVATEL_ACCESS_TOKEN Token sent as api_access_token
BEVATEL_URL Full URL of the Bevatel WhatsApp send endpoint (POST)

Publish config (optional)

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

This copies config/whatsapp.php, which reads the same env keys above.

Register the service provider

The package does not declare Laravel auto-discovery. Register it manually:

Laravel 11+ — in bootstrap/providers.php:

AhmedTaha\WhatsAppBevatel\WhatsAppServiceProvider::class,

Laravel 9–10 — in config/app.php under providers:

AhmedTaha\WhatsAppBevatel\WhatsAppServiceProvider::class,

Optional: register the facade alias in config/app.php (aliases) so you can call WhatsApp::message() instead of resolving WhatsappService manually:

'WhatsApp' => AhmedTaha\WhatsAppBevatel\Facades\WhatsApp::class,

Usage

Build a template payload with WhatsappMessageBuilder, then call send() to POST JSON to BEVATEL_URL with the headers Bevatel expects (api_account_id, api_access_token, Content-Type: application/json).

Minimal example (template + phone + inbox)

use AhmedTaha\WhatsAppBevatel\Enums\WhatsappTemplateLanguage;
use AhmedTaha\WhatsAppBevatel\WhatsappService;

/** @var WhatsappService $whatsapp */
$whatsapp = app(WhatsappService::class);

$response = $whatsapp->message()
    ->setInboxId('your-inbox-id')
    ->setPhone('966501234567')
    ->setTemplate('your_template_name', WhatsappTemplateLanguage::EnUs)
    ->send();

if ($response->successful()) {
    // handle success
} else {
    // $response->status(), $response->body(), etc.
}

Body parameters

Map template body placeholders to the API shape your Bevatel template expects (often an array of parameter objects):

$whatsapp->message()
    ->setInboxId('...')
    ->setPhone('...')
    ->setTemplate('order_update', WhatsappTemplateLanguage::Ar)
    ->setBody([
        // structure must match Bevatel / your approved template
    ])
    ->send();

Header and media

use AhmedTaha\WhatsAppBevatel\Enums\WhatsappMediaType;

$whatsapp->message()
    // ...
    ->setHeader([ /* header parameters */ ])
    ->setMedia(
        'https://example.com/file.pdf',
        WhatsappMediaType::Document,
        'invoice.pdf'
    )
    ->send();

Buttons

Each addButton() sets one button (index increments automatically):

use AhmedTaha\WhatsAppBevatel\Enums\WhatsappButtonSubType;

$whatsapp->message()
    // ...
    ->addButton(WhatsappButtonSubType::QuickReply, 'Yes')
    ->addButton(WhatsappButtonSubType::Url, 'Open link')
    ->send();

Enums

  • WhatsappTemplateLanguage: EnUs (en_US), Ar (AR)
  • WhatsappMediaType: Image, Document
  • WhatsappButtonSubType: Url, QuickReply, CopyCode

Exact template names, languages, and parameter shapes must match what Bevatel approved for your WhatsApp Business account.

Response

send() returns Illuminate\Http\Client\Response from Laravel’s HTTP client, so you can use successful(), json(), body(), status codes, etc.

License

MIT. See the package composer.json if a separate license file is added later.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固