tjmugova / bluedot-sms
为Laravel提供BluedotSms通知渠道
1.0.4
2023-04-25 14:03 UTC
Requires
- php: >=7.3|^8.1
- illuminate/events: ^8.0 || ^9.0 || ^10.0
- illuminate/notifications: ^8.0 || ^9.0 || ^10.0
- illuminate/queue: ^8.0 || ^9.0 || ^10.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
README
一个用于通过bluedot-mobile服务发送通知的Laravel包。
安装 🚀
将包添加到您的composer.json中
"require": {
...
"tjmugova/bluedot-sms": "{version}"
},
或者直接运行composer require
$ composer require tjmugova/bluedot-sms
配置
将您的Bluedot API ID、API 密码、API URL和发送号码添加到.env
BLUEDOTSMS_API_URL=https://rest.bluedotsms.com/api/SendSMS # always required BLUEDOTSMS_API_ID=ZYX # always required BLUEDOTSMS_API_PASSWORD=ABCD # always required BLUEDOTSMS_SMS_FROM=1234 # always required
高级配置
运行php artisan vendor:publish --provider="Tjmugova\BluedotSms\BluedotSmsProvider"
/config/bluedot-sms.php
用法 ✅
有关完整文档,请参阅Laravel通知文档
发送通知
要发送通知,您可以使用Laravel通知外观,并将手机号码作为第一个参数传递
public function send ()
{
Notification::send('263777777777', new LeadAddedNotification());
Notification::send(['263777777777', '263777777777'], new LeadAddedNotification());
}
格式化Viber通知
如果通知支持作为Bluedot消息发送,您应该在通知类上定义一个toBluedotSms方法。此方法将接收一个$notifiable实体,并应返回一个Snp\Notifications\Rml\Messages\ViberMessage实例。让我们看看基本的toRMLViber示例
use Tjmugova\BluedotSms\Messages\ViberMessage;
...
/**
* Get the BluedotSms representation of the notification.
*
* @param mixed $notifiable
* @return Tjmugova\BluedotSms\Messages\BluedotSmsMessage
*/
public function toBluedotSms($notifiable)
{
return (new BluedotSmsMessage('This is a test message from Laravel'));
}
注意
如果您发现任何错误,或者您有一些想法可以使这个包变得更好,请不要犹豫,创建一个pull request。
如果您觉得这个包很有用,简单的star就非常感激。
MIT许可证