PHP code example of superman2014 / laravel-sms-manager

1. Go to this page and download the library: Download superman2014/laravel-sms-manager 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/ */

    

superman2014 / laravel-sms-manager example snippets


    php artisan vendor:publish



return [

    'default' => 'aliyunsms',

    'sms' => [
        'aliyunsms' => [
            'driver' => 'aliyunsms',
            'client_id' => env('ALIYUN_SMS_CLIENT_ID', null),
            'client_secret' => env('ALIYUN_SMS_CLIENT_SECRET', null),
            'sign_name' => env('ALIYUN_SMS_SIGN_NAME', null), //对应下面,而且是默认签名
            'end_point' => env('ALIYUN_SMS_END_POINT', null),
            'template_codes' => [
                'SMS_1234' => [
                    'name' => '测试验证码',
                    'scopes' => ['captcha'],
                    'sign_name_key' => 'sign_name',//对应上面的sign_name,默认读取sign_name,也可以重定义,便于支持多个不同的签名
                ],
            ],
        ],
    ],
];

php artisan tinker
Psy Shell v0.7.2 (PHP 7.0.15 — cli) by Justin Hileman

>>> use Sms;
=> null
>>> $paramString = ['captcha' => 1234];
=> [
     "captcha" => 1234,
   ]
>>> $a = Sms::driver()->prepare('18512345678', $paramString, 'SMS_1234')->send();
>>> $a = Sms::driver('aliyunsms')->prepare('18512345678', $paramString, 'SMS_1234')->send();


支持营销短信变量为空
>>> $a = Sms::driver()->prepareV20170606('18512345678', [], 'SMS_1234')->sendV20170606();