用户手机号获取验证码注册源码分享

阅读更多
叮~

你的源码分享纯干货到了,

请注意查收!

用户手机号注册源码分享,首页获取验证码,调用阿里大鱼短信验证码,接口thinkphp5.2写的,可以判断手机号是否注册,短信发送是否成功。



       
               
               
               
                title
               
               
               

       
       

               

                       

                                   

  •                                        

                                                   

                                                           
                                                   

                                                   

                                                           
                                                   

                                           

                                   

  •                                

  •                                        

                                                   

                                                           
                                                   

                                                   

                                                           
                                                   

                                                   

                                                           
                                                   

                                           

                                   

  •                        

               

               

                       
                       
               


       
       
       


php接口代码:

//注册获取手机验证码接口
    public function getCode()
    {
        $code = Request::instance()->post('code_str');
        $mobile = Request::instance()->post('mobile');
        $signature = Request::instance()->post('signature');
        $str = Db::table('member')->where('phone', $mobile)->find();
        if ($str) {
            // echo 3;
            $res['code'] = 3;
        } else {
            if ($signature == '************') {
                Loader::import('AlibabaAliqinFcSmsNumSendRequest', EXTEND_PATH);
                Loader::import('TopClient', EXTEND_PATH);
                Loader::import('ResultSet', EXTEND_PATH);
                Loader::import('RequestCheckUtil', EXTEND_PATH);
                Loader::import('TopLogger', EXTEND_PATH);
                $c = new \TopClient;
                $c->appkey = '';//换成自己的
                $c->secretKey = '';//换成自己的
                $req = new \AlibabaAliqinFcSmsNumSendRequest;
                $req->setExtend("123456");
                $req->setSmsType("normal");
                $req->setSmsFreeSignName("");//换成自己的
                $req->setSmsParam("{\"code\":\"$code\",\"product\":\"注册\"}");
                $req->setRecNum("$mobile");
                $req->setSmsTemplateCode("SMS_2575466");
                $resp = $c->execute($req);
                if ($resp) {
                    // echo 1;
                    $res['code'] = 1;
                } else {
                    // echo 2;
                    $res['code'] = 2;
                }
            } else {
                // echo 3;
                $res['code'] = 3;
            }
        }
        echo json_encode($res);
    }

你可能感兴趣的:(app开发,前端开发,互联网,代码)