kevinpurwito / laravel-zenziva
Laravel 的 Zenziva 集成
1.0.0
2021-08-11 06:58 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^6.19.0
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.3
README
Laravel Zenziva 是一个集成 Zenziva 的 Laravel 包。
安装
您可以通过 composer 安装此包
composer require kevinpurwito/laravel-zenziva
配置
vendor:publish
命令将在您的 Laravel 项目配置文件夹内发布一个名为 kp_zenziva.php
的文件,位于 config/kp_zenziva.php
。
已发布配置文件内容
[ 'type' => strtolower(env('KP_ZENZIVA_TYPE', 'console')), // gsm or console 'userkey' => env('KP_ZENZIVA_USERKEY'), 'passkey' => env('KP_ZENZIVA_PASSKEY'), ];
或者,您可以忽略上述发布命令,并将以下变量添加到您的 .env
文件中。
KP_ZENZIVA_TYPE=console
KP_ZENZIVA_USERKEY=user
KP_ZENZIVA_PASSKEY=secret
自动发现
如果您使用的是 Laravel 5.5+,您不需要手动添加服务提供者或外观。这将是自动发现的。对于所有低于 5.5 版本的 Laravel,您必须手动将 ServiceProvider & Facade 添加到您的 Laravel 项目 config/app.php
中的适当数组。
提供者
[ Kevinpurwito\LaravelZenziva\ZenzivaServiceProvider::class, ];
别名 / 外观
[ 'Zenziva' => Kevinpurwito\LaravelZenziva\ZenzivaFacade::class, ];
用法
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva; // returns the balance/credit that you have Zenziva::getBalance(); // returns the balance/credit that you have, including the expiry date of the balance Zenziva::balance(); // send SMS Zenziva::sendSms('+62xxx', 'message'); // send Whatsapp message Zenziva::sendWa('+62xxx', 'message'); // send Whatsapp file from URL, including a caption/message Zenziva::sendWaFile('+62xxx', 'message', 'https://image.com/image.png'); // GSM only feature to send SMS OTP Zenziva::sendOtp('+62xxx', '123xxx'); // Console only feature to send voice message Zenziva::sendWa('+62xxx', 'message');
sendWaFile()
接受的文件类型为:.doc .pdf .xls .xlsx .csv .gif .jpg .mp4 .mp3
处理响应
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva; // returns the balance/credit that you have $response = Zenziva::sendWa('+62xxx', 'message'); if ($response->getStatusCode() == 201) { // if you want to check the response body, such as `messageId` you can do this: $content = json_decode($response->getBody()->getContents()); dump($content); // { // "messageId":"157365", // "to":"+62xxx", // "status":"1", // "text":"Success" // } }
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近有哪些更改。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全性
如果您发现任何与安全相关的问题,请通过电子邮件 kevin.purwito@gmail.com 联系,而不是使用问题跟踪器。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。
Laravel 包模板
此包使用 PHP 包模板 生成,由 Beyond Code 提供,并进行了一些修改,灵感来自 PHP 包骨架,由 spatie 提供。