fomvasss / laravel-notification-channel-turbo-sms
此包使您能够轻松使用 Laravel 5.5+ 通过 [turbosms.ua](https://turbosms.ua) 发送通知
1.3.0
2024-09-25 15:33 UTC
Requires
- php: >=7.2
- illuminate/notifications: ^5.5|^6|^7|^8|^9|^10|^11
- illuminate/support: ^5.5|^6|^7|^8|^9|^10|^11
README
以下是 Laravel 通知系统的最新文档
https://laravel.net.cn/docs/master/notifications
此包使您能够轻松使用 turbosms.ua 通过 Laravel 5.5+ 发送通知。
内容
安装
使用 Composer 安装此包
composer require fomvasss/laravel-notification-channel-turbo-sms
服务提供者会自动加载。或者您也可以手动进行
// config/app.php 'providers' => [ ... NotificationChannels\TurboSms\TurboSmsServiceProvider::class, ],
设置 TurboSms 服务
将您的 TurboSms 令牌、默认发送者名称(或电话号码)、测试模式添加到 config/services.php
// config/services.php ... 'turbosms' => [ 'api_token' => env('TURBOSMS_API_TOKEN'), 'sender' => env('TURBOSMS_SENDER'), // for test sending use TAXI 'is_test' => env('TURBOSMS_IS_TEST'), // optional 'timeout' => env('TURBOSMS_TIMEOUT'), 'connect_timeout' => env('TURBOSMS_CONNECT_TIMEOUT'), ], ...
使用
您可以在通知内的 via()
方法中使用此通道
use Illuminate\Notifications\Notification; use NotificationChannels\TurboSms\TurboSmsMessage; use NotificationChannels\TurboSms\TurboSmsChannel; class AccountApproved extends Notification { public function via($notifiable) { return [TurboSmsChannel::class]; } public function toTurboSms($notifiable) { return (new TurboSmsMessage())->content("Hello SMS!!!")->test(true); } }
在您的可通知模型中,确保包含一个返回电话号码或电话号码数组的 routeNotificationForTurboSms()
方法。
public function routeNotificationForTurboSms() { return $this->phone; }
可用方法
from()
: 设置发送者的名称或电话号码。
content()
: 设置通知消息的内容。
time()
: 示例参数 = time() + 7*60*60
- 延迟发送 7 小时。
test()
: 测试 SMS 发送(日志)
变更日志
有关最近更改的更多信息,请参阅 变更日志。
安全
如果您发现任何安全相关的问题,请通过电子邮件发送到 fomvasss@gmail.com 而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING。
致谢
许可
MIT 许可证(MIT)。请参阅 许可文件 以获取更多信息。