laravel-notification-channels / infobip
适用于 Laravel 的 Infobip 通知通道
1.1.0
2020-10-08 21:25 UTC
Requires
- php: >=7.2
- illuminate/notifications: ~5.5 || ~6.0 || ~7.0 || ~8.0
- illuminate/support: ~5.5 || ~6.0 || ~7.0 || ~8.0
- infobip/infobip-api-php-client: dev-master
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^5.3
- phpunit/phpunit: ^8.0
README
此包使得在 Laravel 5.5+、6.x 和 7.x 中使用 Infobip 发送通知变得容易
内容
安装
您可以通过 composer 安装此包
composer require laravel-notification-channels/infobip
设置您的 Infobip 账户
将您的 Infobip 产品令牌和默认发件人(名称或发件人号码)添加到您的 config/services.php
// config/services.php ... 'infobip' => [ 'username' => env('INFOBIP_USERNAME'), 'password' => env('INFOBIP_PASSWORD'), 'from' => env('INFOBIP_FROM', 'Info'), 'notify_url' = env('INFOBIP_NOTIFY_URL', null), ], ...
要更改 Base URL
以供个人使用,请参阅此链接(更多信息)
... 'infobip' => [ ... 'baseUrl' => env('INFOBIP_BASE_URL', null), ], ...
使用方法
您可以在通知中的 via() 方法中使用该通道
use Illuminate\Notifications\Notification; use NotificationChannels\Infobip\InfobipMessage; class AccountApproved extends Notification { public function via($notifiable) { return ["infobip"]; } public function toInfobip($notifiable) { return (new InfobipMessage)->content("Your account was approved!"); } }
在您的可通知模型中,确保包含一个 routeNotificationForInfobip() 方法,该方法返回一个电话号码或电话号码数组。
public function routeNotificationForInfobip() { return $this->phone_number; }
按需通知
有时您可能需要向未存储为您的应用程序“用户”的人发送通知。使用 Notification::route 方法,您可以在发送通知之前指定临时的通知路由信息
Notification::route('infobip', '5555555555') ->notify(new InvoicePaid($invoice));
可用的消息方法
from('')
:接受一个用于通知发送者的电话号码/发送者名称。 请确保在您的 Infobip 控制台中注册发送者名称。
content('')
:接受用于通知正文的字符串值。
变更日志
有关最近更改的更多信息,请参阅变更日志
测试
$ composer test
安全
如果您发现任何安全相关的问题,请通过电子邮件cliff@nyumbanitechnologies.com联系,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅贡献指南
致谢
许可证
MIT 许可证(MIT)。请参阅许可证文件获取更多信息。