alexvexone / laravel-opersms
OperSMS集成服务
1.3.1
2023-06-21 05:11 UTC
Requires
- php: >=8.1
- ext-curl: *
- laravel/framework: ^9.0|^10.0
README
安装
composer require alexvexone/laravel-opersms
该包使用Laravel包发现,因此不需要明确声明服务提供者。
在.env
中需要配置连接到OperSMS的指令
OPERSMS_LOGIN=YOUR_LOGIN
OPERSMS_PASSWORD=YOUR_PASSWORD
默认请求发送到 http://83.69.139.182:8080
,如果需要更改URL,请重写指令
OPERSMS_URL=YOUR_URL
如果需要通过SSL连接
OPERSMS_SSL_VERIFICATION=true
使用方法
通过Laravel通知
public function via(object $notifiable) { return ['opersms']; }
或者
public function via(object $notifiable) { return [\Alexvexone\LaravelOperSms\Channels\OperSmsChannel::class]; }
通过服务直接调用
向一个电话号码发送一条消息
\Alexvexone\LaravelOperSms\OperSmsService::send('YOUR_PHONE', 'YOUR_TEXT');
向不同的电话号码发送不同的消息
\Alexvexone\LaravelOperSms\OperSmsService::send(['YOUR_PHONE1', ...], ['YOUR_TEXT1', ...]);
向一个电话号码发送不同的消息
\Alexvexone\LaravelOperSms\OperSmsService::send('YOUR_PHONE', ['YOUR_TEXT1', ...]);
通过自定义数组进行批量发送
\Alexvexone\LaravelOperSms\OperSmsService::send([['phone' => 'YOUR_PHONE1', 'text' => 'YOUR_TEXT1'], ...]);
通过ID检查发送短信的状态
\Alexvexone\LaravelOperSms\OperSmsService::status(YOUR_ID);
发布(可选)
php artisan vendor:publish --provider="Alexvexone\LaravelOperSms\Providers\OperSmsServiceProvider"