nuwira / laravel-sms-notification
Nuwira SMS Notifications for Laravel
1.0
2016-10-20 16:57 UTC
Requires
- php: >=5.6.4
- illuminate/notifications: ^5.3
- illuminate/support: ^5.3
- nuwira/smsgw: ~2.3
Requires (Dev)
- fzaninotto/faker: ^1.6
- mockery/mockery: ^0.9.5
- phpunit/phpunit: ^5.6
This package is auto-updated.
Last update: 2024-09-21 21:11:49 UTC
README
此包通过 Laravel 5.3 使用 Nuwira SMS 网关轻松发送短信通知。
内容
要求
登录到 Nuwira SMS 网关,然后创建一个应用,该应用将为您提供客户端 ID 和客户端密钥。
安装
您可以通过 composer 安装此包
composer require nuwira/laravel-sms-notification
您必须安装服务提供者
// config/app.php 'providers' => [ ... Nuwira\LaravelSmsNotification\SmsServiceProvider::class, ],
使用此命令发布配置
php artisan vendor:publish --provider="Nuwira\LaravelSmsNotification\SmsServiceProvider"
打开 config/sms.php
文件并编辑配置,或者您可以使用 .env
文件并填写客户端 ID 和客户端密钥。
NUWIRA_SMSGW_CLIENT_ID=client_id
NUWIRA_SMSGW_CLIENT_SECRET=client_secret
使用
现在您可以在 Notification 类的 via()
方法中使用该通道。
namespace App\Notifications; use Nuwira\LaravelSmsNotification\SmsChannel; use Nuwira\LaravelSmsNotification\SmsMessage; use Illuminate\Notifications\Notification; class SendNotificationToSms extends Notification { public function via($notifiable) { return [SmsChannel::class]; } public function toSms($notifiable) { return (new SmsMessage()) ->to($phoneNumber) ->content($content); } }
可用方法
to($phoneNumber)
:(string)
接收者电话号码。强烈建议使用国际电话号码格式(+62XXXXXXXXXX)。content($message)
:(string)
短信内容。如果内容长度超过 160 个字符,它将自动作为 长短信 发送。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 zam@nuwira.co.id 而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING。
致谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件。