/** * 根据注册用户的手机号,获取手机验证码 * @param $tel */ public function getSmsCode($tel) { //生成随机的短信验证码 $smsCode = \Org\Util\String::randNumber(1000, 9999); //将手机验证码存入redis中,当前手机号作为键.用作后面的验证 S($tel, $smsCode, 60); //发送验证信息 sendSMS('注册验证', '{"code":"' . $smsCode . '","product":"京西商城"}', $tel, 'SMS_4730837'); }
/** * 获取短信的验证码 * @param $tel */ public function getSMSCode($tel) { //随机码 $str = String::randNumber(1000, 9999); //>>1.将验证码保存到redis中.保存30秒 S($tel, $str, 300); //>>2.发送短信 sendSMS('注册验证', '{"code":"' . $str . '","product":"京西商城"}', $tel, 'SMS_2245271'); }
/** * 发送短信验证码,放到redis中 * @param $tel */ public function sendSMS($tel) { //得到随机6位数字 $strObj = new String(); $telCode = $strObj->randNumber(100000, 999999); //保存在redis中 5分钟有效期 S($tel, $telCode, 300); //构建短信参数 $str = '{"code":"' . $telCode . '","product":"京西商城"}'; //发送短信 sendSMS($str, $tel); $this->ajaxReturn(true); }
/** * 获取短信的验证码 * @param $tel */ public function getSMSCode($tel) { //获取随机码 $str = String::randNumber(1000, 9999); //将验证码保存到redis中,保存5分钟 S($tel, $str, 300); //发送短信 sendSMS('注册验证', '{"code":"' . $str . '","product":"京西商城"}', $tel, 'SMS_4830036'); }