axolotesource/laravel-whatsapp-api

此Laravel扩展包使您能够在应用程序中无缝发送WhatsApp消息。通过简单的集成,它使开发者能够轻松地将WhatsApp消息功能集成到应用程序中,从而以直观的方式增强用户参与度和通信。

1.0.0 2023-11-21 08:07 UTC

This package is not auto-updated.

Last update: 2024-09-25 10:17:37 UTC


README

安装

composer require axolotesource/laravel-whatsapp-api

要发布配置文件,请运行以下命令

php artisan vendor:publish

当被提示选择提供商时,请选择Axolotesource\LaravelWhatsappApi\LaravelWhatsappApiServiceProvider。

WhatsApp消息

示例

templete(string $to, string $templateName = null): Template

此方法允许您发送模板类型消息(这是应首先发送给客户端的消息)。对于第二个参数,它可以是null,如果是null,则从config('laravel-whatsapp-api.default_initial_template');获取值。

$whatsappMessage = WhatsAppMessages::templete($phoneNumber)
    ->language('es_MX')
    ->addComponents([
        BodyComponent::create([
            Params::text('This is a test message')
        ]),
        ButtonComponent::create([
            Params::button('yes')
        ]),
        ButtonComponent::create([
            Params::button('no')
        ]),
        ButtonComponent::create([
            Params::button('never')
        ])
    ]);
interactiveButtons(string $to): InteractiveButtons
WhatsAppMessages::interactiveButtons($phoneNumber)
    ->setHeaderImage(
        'https://url.com/test.jpg'
    )
    ->addButton('Button 1', 1)
    ->addButton('Button 2', 2)
    ->addButton('Button 3', 3)
    ->body('This is te body message')
    ->send();

更多文档即将推出...