短信发送
一、安装
composer require oh86/laravel-sms
php artisan vendor:publish
# 可选
composer require tencentcloud/sms
二、配置
return [
'default' => env('SMS_DEFAULT_DRIVER', 'tencentCloudApp1'),
'drivers' => [
//
'tencentCloudApp1' => [
'service' => 'tencentCloud', // 腾讯云短信服务
// 云平台配置
'platform' => [
'secretId' => env('TENCENT_CLOUD_SECRET_ID'),
'secretKey' => env('TENCENT_CLOUD_SECRET_KEY'),
'region' => env('TENCENT_CLOUD_REGION', 'ap-guangzhou'),
],
// 应用配置
'app' => [
'appId' => env('TENCENT_CLOUD_SMS_APP_ID'),
'sign' => env('TENCENT_CLOUD_SMS_SIGN'),
'templateId' => env('TENCENT_CLOUD_SMS_TEMPLATE_ID'),
]
],
],
];
三、使用示例
SMS::send(['15014153877', '15014153878'], ['123456']);
SMS::driver('tencentCloudApp1')->send(['15014153877', '15014153878'], ['123456']);
四、拓展
1.拓展service
app()->get(\Oh86\SMS\SMSManager::class)->extendService('serviceDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface {
// TODO
});
2.拓展driver
app()->get(\Oh86\SMS\SMSManager::class)->extend('driverDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface {
// TODO
});