PHP code example of dh2y / think-sms-temp

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

    

dh2y / think-sms-temp example snippets


$sms = Sms::getInstance();

//注册短信验证码
$result = $sms->sendSmsCode($phone,'register'); 
  
//找回密码证码
$result = $sms->sendSmsCode($phone,'retrieve');   

//普通短信验证码
$result = $sms->sendSmsCode($phone,'common',null,rand('111111','999999'));   

//更改手机号码
$result = Sms::getInstance()->sendSmsCode($phone,'changePhone',function ($p,$c){
            session('phone', $p);
            session('resms', $c);
            session('smsexpire', time() + 60);
            session('smstime', time() + 60);
        });

//验证短信验证码
$sms->verifySmsCode('17xx11076xx',587620);