PHP code example of mythinking / laravel-sms

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

    

mythinking / laravel-sms example snippets

`
    use Sms; 
    
    $server = Sms::server();
    $server->setConfig(config("sms.cl"));//支持多账号配置,默认cl配置
    $res = $server->send('15988888888','registerCode', ['code'=>123456], function ($res, $data) {
        Log::info($res);//接口返回结果, code=0 成功
            array:3 [▼
              "code" => 101
              "msg" => "无此用户"
              "data" => array:2 [▼
                "msgid" => ""
                "time" => "20190905160335"
              ]
            ]
        Log::info($data);//渠道方返回结果
                array:2 [▼
                  "msg" => "【xxx】您的验证码为:123456,请在三分钟内输入。为了保障您的账户安全,请勿将验证码短信转发他人"
                  "res" => "{"code":"101","msgId":"","time":"20190905160047","errorMsg":"无此用户"}"
                ]
        // db record
        ...
    });
    
    
    //清除限制缓存
    $server->clearLimit('15988888888');