alif/alif-sms-notification
最新稳定版本:v2.1.0
Composer 安装命令:
composer require alif/alif-sms-notification
包简介
README 文档
README
prerequisites
To use this package you need:
- composer 2.2 and above
- php 8.1 and above
- guzzlehttp/guzzle
- laravel 9 and above
Installation
install package by running the below commands:
composer require alif/alif-sms-notification
it will create and past the following code in the file named config/sms-notification.php
<?php return [ 'host' => env('SMS_NOTIFICATION_HOST'), 'method' => 'POST', 'headers' => [ 'X-Api-Key' => env('SMS_NOTIFICATION_API_KEY'), 'Content-type' => 'application/json', 'charset' => 'utf-8' ], 'routes' => [ 'send_sms' => '/api/v1/Sms' ], ];
Usage
- simple send
$smsSender = new SmsNotificationSender(); //OR $smsSender = SmsNotificationSender::make(); $smsSender->from('John Doe') ->to('123456789') ->send('Message text'); //or SmsNotificationSender::make() ->from('John Doe') ->to('123456789') ->send('Message text');
- send async
$smsSender = new SmsNotificationSender(); //OR $smsSender = SmsNotificationSender::make(); $smsSender->from('John Doe') ->to('123456789') ->sendAsinc('Message text');
- handle exceptions
$smsSender = SmsNotificationSender::make(); $smsSender->from('John Doe') ->to('123456789') ->onFail(function(Exception $e) { // do something ... })->onSuccess(function(ResponseInterface $response) { // do smth ... })->send('Message text');
- with headers
$smsSender = SmsNotificationSender::make(); $smsSender->from('John Doe') ->to('123456789') ->headers($headers) ->onFail(function(Exception $e) { //... })->onSuccess(function(ResponseInterface $response) { //... })->send('Message text');
$smsSender = SmsNotificationSender::make(); $smsSender->from('John Doe') ->to('123456789') ->priority($priority) ->onFail(function(Exception $e) { //... })->onSuccess(function(ResponseInterface $response) { //... })->send('Message text');
- set expiresIn
$smsSender->from('John Doe') ->to('123456789') ->expiresIn($expiresIn) ->onFail(function(Exception $e) { //... })->onSuccess(function(ResponseInterface $response) { //... })->send('Message text');
- set countryCode
$smsSender->from('John Doe') ->to('123456789') ->countryCode($countryCode) ->onFail(function(Exception $e) { //... })->onSuccess(function(ResponseInterface $response) { //... })->send('Message text');
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-26
