先下载类文件包,解压到lib文件下,到入口文件中定义一个新的路径,引入类文件。
param("name"); $data['password']=Request::instance()->param("password"); $data['phone']=Request::instance()->param("phone"); $data['regtime']=date('Y-m-d H:i:s'); $code1=Request::instance()->param("code"); $code=Session::get('code'); if($code1!=$code){ return $this->error("验证码错误"); }else{ $res=Db::table('phones')->insert($data); if($res){ return $this->success("注册成功"); }else{ return $this->success("注册失败"); } } } //发送验证码 public function sendMoblieCode(){ //接收手机号 $phone=Request::instance()->param("phone"); //生成验证码 $code=rand(100000,999999); //引入类文件 require_once EXTEND_PATH."Phone.php"; //主账号 $accountSid= '8aaf070866235bc501667f9e877c3421'; //主账号Token $accountToken= 'aef9c6aa26f04085bda5594c9b25397f'; //应用Id $appId='8aaf070866235bc501667f9e87d53427'; //请求地址 $serverIP='app.cloopen.com'; //端口号 $serverPort='8883'; //REST版本号 $softVersion='2013-12-26'; //设置接口参数 $rest = new REST($serverIP,$serverPort,$softVersion); $rest->setAccount($accountSid,$accountToken); $rest->setAppId($appId); //发送验证码 $result=$rest->sendTemplateSMS($phone,array($code,60),'1'); if($result){ Session::set('code',$code); return 1; }else{ return 0; } }}
用户注册页面