作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

个人中心接口

... ... @@ -66,11 +66,17 @@ class UserController extends RestBaseController
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:mobile require:1
* @param name:code require:1
*/
public function mobile(){
$param=$this->request->param();
$re = cmf_check_verification_code($param['mobile'], $param['code'], true);
if ($re == "") {
Db::name('user')->where('id',$this->getUserId())->update(['mobile'=>$param['mobile']]);
$this->success('注册提交成功');
} else {
$this->error($re);
}
}
/**
... ... @@ -83,19 +89,22 @@ class UserController extends RestBaseController
* @param name:mobile require:1
*/
public function getCode(){
$param=$this->request->param();
$param['mobile']=17694933850;
// require_once VENDOR_PATH . "sms/serverSid.php";
require_once VENDOR_PATH . "sms/lib/Ucpaas.class.php";
$param=$this->request->param();
$options['accountsid']='d63e23ab657c95babad1681133dbabdc';
//填写在开发者控制台首页上的Auth Token
$options['token']='1fc7377f48edb5bf1659284210f16418';
$send=new \Ucpaas($options);
$code = cmf_get_verification_code($param['mobile'], 4);
$appid = "78950d10e37b4ae5bd9b9c08f3720db3"; //应用的ID,可在开发者控制台内的短信产品下查看
$templateid = "41494"; //可在后台短信产品→选择接入的应用→短信模板-模板ID,查看该模板ID
$uid = "";
//70字内(含70字)计一条,超过70字,按67字/条计费,超过长度短信平台将会自动分割为多条发送。分割后的多条短信将按照具体占用条数计费。
echo $send->SendSms($appid,$templateid,$code,$param['mobile'],$uid);
$send=new \Ucpaas($options);
$send->SendSms($appid,$templateid,$code,$param['mobile'],$uid);
cmf_verification_code_log($param['mobile'], $code, 180);
$this->success('验证码发送成功');
}
}
... ...
... ... @@ -1169,7 +1169,7 @@ function cmf_get_verification_code($account, $length = 6)
if (empty($account)) return false;
$verificationCodeQuery = Db::name('verification_code');
$currentTime = time();
$maxCount = 5;
$maxCount = 20;
$findVerificationCode = $verificationCodeQuery->where('account', $account)->find();
$result = false;
if (empty($findVerificationCode)) {
... ...