PHP code example of ddsm2016 / sv

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

    

ddsm2016 / sv example snippets


$table->string('id');
$table->string('code', 8);
$table->tinyInteger('dayget', false, true)->default(1);
$table->tinyInteger('verifyed', false, true)->default(0);
$table->timestamps();
// 主键定义
$table->primary('id');

$config = [
	'expire_time' => 1800,  // 验证码有效期(秒)
	'get_max'     => 3, // 每天最多可获取验证码次数
	'verify_max'  => 3, // 每条验证码最大可试错次数
];

$sv = SmsVerify::instance($id);  // 设置验证码记录ID,返回当前对象$this

$sv->config($config); // 设置配置项,返回当前对象$this

$sv->model($model);  // $model为短信验证码Eloquent模型,返回当前对象$this

/**
 * 发送短信验证码
 * @param string $phone 接收验证码手机号码
 * @return bool
 */
$sv->sms($sms)->content($template)->send($phone);

/**
 * 短信验证码验证
 * @param string $inputCode 粉丝输入待验证的验证码
 * @return bool
 */
$sv->verify($inputCode);

$sv->error();  // 用于获取最后一次产生的错误信息