博客> 用户手机号获取验证码注册源码分享
用户手机号获取验证码注册源码分享
2018-07-20 17:55 评论:0 阅读:660 were1234
app开发 互联网 前端开发 程序员开发

叮~

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

请注意查收!

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

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"> <title>title</title> <link rel="stylesheet" type="text/css" href="../css/api.css"/> <link rel="stylesheet" type="text/css" href="../css/style.css" /> <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />

    &lt;/head&gt;
    &lt;body&gt;

            <div class="aui-content aui-margin-b-15">
                    <ul class="aui-list aui-form-list">
                            <li class="aui-list-item">
                                    <div class="aui-list-item-inner">
                                            <div class="aui-list-item-label-icon">
                                                    <i class="aui-iconfont aui-icon-mobile"></i>
                                            </div>
                                            <div class="aui-list-item-input">
                                                    &lt;input type="text" placeholder="手机号" id="mobile"&gt;
                                            </div>
                                    </div>
                            </li>
                            <li class="aui-list-item">
                                    <div class="aui-list-item-inner">
                                            <div class="aui-list-item-label-icon">
                                                    <i class="aui-iconfont aui-icon-lock"></i>
                                            </div>
                                            <div class="aui-list-item-input">
                                                    &lt;input type="text" placeholder="验证码" id="code"&gt;
                                            </div>
                                            <div class="aui-list-item-label-icon">
                                                    <i class="aui-iconfont aui-icon-display"></i>
                                            </div>
                                    </div>
                            </li>
                    </ul>
            </div>
            <div align="center">
                    &lt;button type="button"  onclick="get_code();"&gt;
                            获取验证码
                    &lt;/button&gt;
                    &lt;button type="button"  onclick="next_reg();"&gt;
                            下一步
                    &lt;/button&gt;
            </div>

    &lt;/body&gt;
    [removed][removed]
    [removed]
            var mobile = document.getElementById("mobile");
            var code = document.getElementById("code");
            var code_str = "";
            for (var i = 0; i < 6 xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed>

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); }

收藏
0
sina weixin mail 回到顶部