PHP code example of oh86 / laravel-sms

1. Go to this page and download the library: Download oh86/laravel-sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oh86 / laravel-sms example snippets


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']);


app()->get(\Oh86\SMS\SMSManager::class)->extendService('serviceDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface {
    // TODO
});

app()->get(\Oh86\SMS\SMSManager::class)->extend('driverDemo', function ($app): \Oh86\SMS\Services\SMSServiceInterface {
    // TODO
});