sevenspan/laravel-value-first

它使用 ValueFirst API 发送 WhatsApp 消息。

v3.3 2023-09-19 13:22 UTC

README

它使用 ValueFirst API 发送 WhatsApp 消息。

安装

您可以通过 composer 安装此包

composer require sevenspan/laravel-value-first

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="SevenSpan\ValueFirst\Providers\ValueFirstServiceProvider" --tag="config"

这是已发布配置文件的内容

return [

    /*
    |--------------------------------------------------------------------------
    | ValueFirst Whatsapp API URI
    |--------------------------------------------------------------------------
    |
    | The ValueFirst Whatsapp Message API URI.
    |
    */

    'api_uri' => env('VALUEFIRST_API_URI',''),

    /*
    |--------------------------------------------------------------------------
    | From Number
    |--------------------------------------------------------------------------
    |
    | The Phone number registered with ValueFirst that your SMS will come from
    |
    */

    'from' => env('VALUEFIRST_FROM',''),

    /*
    |--------------------------------------------------------------------------
    | Username
    |--------------------------------------------------------------------------
    |
    | Your ValueFirst Username
    |
    */

    'username' =>  env('VALUEFIRST_USERNAME',''),

    /*
    |--------------------------------------------------------------------------
    | Password
    |--------------------------------------------------------------------------
    |
    | Your ValueFirst Password
    |
    */

    'password' =>  env('VALUEFIRST_PASSWORD',''),
];

使用方法

用于发送 WhatsApp 文本消息

use ValueFirst;

$to ='9111111111'; // Phone number with country code where we want to send message(Required)
$message ='Hello'; // Message that we want to send(Required)
$tag = 'Whatsapp Message';  //Tag if you want to assign (Optional)

// Without passing tag
$response=ValueFirst::sendMessage($to,$message);

// With passing tag
$response=ValueFirst::sendMessage($to,$message,$tag);

使用模板 ID 发送 WhatsApp 文本消息

use ValueFirst;

$to ='9111111111'; // Phone number with country code where we want to send message(Required)
$templateId = "123"; //Approved template ID by ValueFirst
$data = []; // Array of data to replace template data with dynamic one
$tag = 'Whatsapp Message';  //Tag if you want to assign (Optional)



// Without passing tag
$response=ValueFirst::sendTemplateMessage($to,$templateId,$data);

// With passing tag
$response=ValueFirst::sendTemplateMessage($to,$templateId,$data,$tag);

注意:使用模板 ID 发送 WhatsApp 消息时,数据数组应按照模板动态值的顺序排列。

测试

composer test

变更日志

请参阅 变更日志 了解最近更改的详细信息。

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 获取更多信息。