coreproc / laravel-notification-channel-globe-labs-sms
此包使您能够轻松使用Laravel 5.3、5.4和5.5通过Globe Labs SMS发送通知。
0.3.0
2018-08-01 02:40 UTC
Requires
- php: >=5.6.4
- coreproc/msisdn-ph: ^1.1
- guzzlehttp/guzzle: ^6.2
- illuminate/notifications: ^5.3|^5.4|^5.5|^5.6
- illuminate/support: ^5.3|^5.4|^5.5|^5.6
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-12 07:07:01 UTC
README
此包使用Laravel 5.3及以上版本,通过Globe Labs SMS发送通知变得非常简单。
内容
安装
使用Composer安装此包
composer require coreproc/laravel-notification-channel-globe-labs-sms
在config/app.php中注册ServiceProvider(如果您使用的是Laravel 5.5及以上版本,请跳过此步骤)
Coreproc\GlobeLabsSms\GlobeLabsSmsServiceProvider::class,
设置Globe Labs Sms服务
首先在这里创建项目: http://www.globelabs.com.ph/#!/developer/api/sms
请注意,此包不处理用户订阅Globe Labs SMS应用程序所需的opt-in步骤。
此包假设您已经通过SMS或通过web表单处理了opt-in步骤,并且您已经可以访问订阅者的访问令牌。
注册并设置您的应用程序后,请将短码添加到config/broadcasting.php中的配置中。
'connections' => [ .... 'globe_labs_sms' => [ 'short_code' => env('GLOBE_LABS_SMS_SHORT_CODE'), ], ... ]
用法
在具有Notifiable特质的模型/类中设置routeNotificationForGlobeLabsSms()
方法。例如
class User extends Model { use Notifiable; public function routeNotificationForGlobeLabsSms() { return [ 'access_token' => 'access-token-obtained-from-sms-opt-in-this-could-be-stored-in-your-database', 'address' => '09171234567', // can be any format as long as it is a valid mobile number ]; } }
您现在可以通过在Notification类中创建一个GlobeLabsSmsMessage
来通过Globe Labs发送短信
class AccountActivated extends Notification { public function via($notifiable) { return [GlobeLabsSmsChannel::class]; } public function toGlobeLabsSms($notifiable) { return GlobeLabsSmsMessage::create($notifiable) ->setMessage('This is a test message'); } }
通过在模型/类中调用notify()
方法来调用短信通知。例如
$user = User::find(1); $user->notify(new AccountActivated);
安全
如果您发现任何安全相关的问题,请通过chris.bautista@coreproc.ph发送电子邮件,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅CONTRIBUTING。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。