swiftsmsgh-laravel-notification-channels / swiftsmsgh
swiftsms-GH SMS 通知通道 For Laravel
v1.0.1
2024-01-19 19:32 UTC
Requires
- php: >=8.1
- illuminate/notifications: ~5.0 || ~6.0 || ~7.0 || ~8.0
- illuminate/support: ~5.0 || ~6.0 || ~7.0 || ~8.0
- swiftsmsgh/swiftsmsgh-api-sdk: ^1.0
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^9.6
README
📲 Swiftsmsgh 通知通道 for Laravel
内容
安装
composer require swiftsmsgh-laravel-notification-channels/swiftsmsgh
配置
将您的 Swiftsmsgh SENDER_ID 和 API_TOKEN 添加到您的 .env
SWIFTSMSGH_API_TOKEN=100|hjwewrahwjew8234wej # always required SWIFTSMSGH_SENDER_ID=Demo # always required
将配置添加到您的 services.php
配置文件
'swiftsmsgh' => [ 'sender_id' => env('SWIFTSMSGH_SENDER_ID', 'sender_id'), 'api_token' => env('SWIFTSMSGH_API_TOKEN', 'api_token'), ]
设置 Swiftsmsgh 服务
您需要一个 Swiftsms-GH 账户。请访问他们的 网站 并创建或登录您的账户。
在侧边栏导航到 API 集成
然后 API 令牌
以复制现有的或生成一个 API 令牌。
用法
您可以在通知中的 via()
方法中使用此通道
use Illuminate\Notifications\Notification; use \NotificationChannels\Swiftsmsgh\SwiftsmsghMessage; use \NotificationChannels\Swiftsmsgh\SwiftsmsghChannel; class LoginNeedsVerification extends Notification { public function via($notifiable) { return [SwiftsmsghChannel::class]; } public function Swiftsmsgh($notifiable) { return (new SwiftsmsghMessage) ->content("Task #{$notifiable->id} is complete!") ->from('My App'); } }
在您的可通知模型中,确保包含一个 routeNotificationForSwiftsmsgh()
方法,该方法返回一个包含国家代码的电话号码。
public function routeNotificationForSwiftsmsgh() { return $this->phone; // 0200000001 }
可用方法
sender()
:设置发送者的名称或电话号码。
content()
:设置通知消息的内容。
变更日志
请参阅变更日志了解最近更改的信息。
测试
$ composer test
安全
如果您发现任何与安全相关的问题,请通过电子邮件 support@swiftsmsgh.com 联系我们,而不是使用问题跟踪器。
贡献
请参阅贡献指南了解详细信息。
鸣谢
许可证
MIT 许可证 (MIT)。请参阅许可证文件获取更多信息。