31 lines
769 B
PHP
31 lines
769 B
PHP
<?php
|
|
|
|
require_once APP_PATH.'/sms.php';
|
|
|
|
class Tools
|
|
{
|
|
/**
|
|
* 发送手机验证码
|
|
* @param $phone
|
|
* @param int $captcha
|
|
* @param bool $is_debug
|
|
* @return int
|
|
* @throws Exception
|
|
*/
|
|
public function sendCaptcha($phone, $captcha = 0, $is_debug = false)
|
|
{
|
|
$rand_code = !empty($captcha) ? $captcha : rand(100000, 999999);
|
|
// 是否是测试状态
|
|
if(!$is_debug) {
|
|
$sms = new sms();
|
|
$result = $sms->_SendSms(7, array('code' => $rand_code, 'product' => '代理'), $phone);
|
|
|
|
if ( !is_null($result)) {
|
|
throw new Exception('短信发送太频繁,请稍候再试', ERRORCODE_SMSSENDERROR);
|
|
}
|
|
}
|
|
|
|
return $rand_code;
|
|
}
|
|
|
|
} |