oza75/laravel-orange-sms-channel
一个使用 Orange SMS API 发送短信的通知通道
v0.0.4
2022-11-06 12:40 UTC
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.3
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-06 16:28:02 UTC
README
一个 Laravel 通知通道,用于通过 Orange SMS 向中东和非洲的用户发送短信通知。更多详情请见这里。
安装
您可以通过 composer 安装此包
composer require oza75/laravel-orange-sms-channel
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="Oza75\OrangeSMSChannel\OrangeSMSServiceProvider"
使用方法
首先,您需要在 Orange 开发者网站上创建一个应用程序。访问 https://developer.orange.com/myapps 并创建一个新的应用程序。创建应用程序后,您将获得一个 Client ID
和 Client Secret
。这些凭据将用于与 Orange API 通信。现在,您需要将 Orange SMS API 添加到您的应用程序中。访问 https://developer.orange.com/apis/sms,选择您的国家,然后点击 使用此 API
按钮。
最后,在您的 config/service.php
文件中添加一个新的服务。
// file: config/services.php return [ // ...others services 'orange' => [ 'client_id' => env('ORANGE_CLIENT_ID'), 'client_secret' => env('ORANGE_CLIENT_SECRET'), ] ];
配置通知
在您的通知类中,通过 via 方法添加 orange SMS 通道并创建一个 toOrange
方法。
use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Oza75\OrangeSMSChannel\OrangeMessage; use Oza75\OrangeSMSChannel\OrangeSMSChannel; class ConfirmationNotification extends Notification { use Queueable; /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [OrangeSMSChannel::class]; } // ...others method here /** * Send sms using Orange API * * @param mixed $notifiable * @return OrangeMessage */ public function toOrange($notifiable):OrangeMessage { return (new OrangeMessage()) ->to('+22600000000') ->from('+22600000000') ->text('Sample text'); } }
可用的消息方法
to
(接收者电话号码)from
(发送者电话号码)text
(实际文本消息)
配置文件
<?php return [ /**** * The country code that must be prepend to all phone number. * If the phone number already start with the `+`(plus) symbol, * the country code will not be applied. */ 'country_code' => null, /** * You may wish for all SMS sent by your application to be sent from * the same phone number. Here, you may specify a name and a phone number that is * used globally for all SMS that are sent by your application. */ 'from' => [ 'phone_number' => null, 'name' => env('APP_NAME') ] ];
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 abouba181@gmail.com 而不是使用问题跟踪器。
致谢
许可协议
MIT 许可协议(MIT)。请参阅 许可文件 了解更多信息。
Laravel 包模板
此包是使用 Laravel 包模板 生成的。