发货者 / laravel-winsms-channel
此包的最新版本(v1.1.4)没有可用的许可信息。
WinSMS API 的 Laravel 通知渠道
v1.1.4
2024-03-09 00:23 UTC
Requires
- php: ^7.2|^8.0
- illuminate/notifications: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
README
一个 Laravel 通知渠道,用于向突尼斯用户发送短信通知。更多详情请见https://www.winsms.tn。
安装
您可以通过 composer 安装此包
composer require shipper/laravel-winsms-channel
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="Shipper\WinSMS\WinSMSServiceProvider"
使用方法
首先,您需要拥有一个有效的 WinSMS 账户。请访问 https://www.winsms.tn/ 并创建一个账户。一旦您有权访问您的账户,您将需要获取您的 API KEY
。这些凭证将用于与 Win SMS API 通信。请访问 https://winsmspro.com/sms/user/sms-api/info
最后,在您的 config/service.php
文件中添加一个新的服务。
// file: config/winsms.php return [ 'api_key' => env('WINSMS_API_KEY', ''), 'sender_id' => env('WINSMS_SENDER_ID', ''), ];
配置通知
在您的通知类中,在 via 方法中添加 WinSMS Channel 并创建一个 toWinSMS
方法。
use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Shipper\WinSMS\WinSMSChannel; use Shipper\WinSMS\WinSMSMessage; class ConfirmationNotification extends Notification { use Queueable; /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [WinSMSChannel::class]; } // ...others method here /** * Send sms using WinSMS API * * @param mixed $notifiable * @return array */ public function toWinSMS($notifiable):WinSMSMessage { return (new WinSMSMessage()) ->to($notifiable->phone_number) ->from('MyApp') ->content('Your account has been created successfully'); } }
可用消息方法
to
(接收者电话号码)from
(发送者电话号码)content
(实际文本消息)
使用 Facade
您还可以使用 facade 发送短信通知。
use Shipper\WinSMS\Facades\WinSMS; WinSMS::sendSMS('216XXXXXXXX', 'MyApp', 'Your account has been created successfully');
许可
MIT 许可证(MIT)。请参阅许可文件以获取更多信息。