52471225
Now login registration when our verification method is not single mobile phone to send verification code has become the norm let us together to achieve the following!
First we need to find the interface of the text message I use the cloud Messenger here is his address http://sms.sms.cn/login.php?cgh you can go and register.
1. Enter the view
<ul class= "Register" ><li><label> mobile number: </label><input class= "Ipt-box tel-bg" value= "" id= " Regi_mobile "type=" text "></li><li><label> captcha: </label><input class=" code "value=" Six-digit verification Code "id=" Validatecode "type=" text "><input class=" code "onclick= ' Duanxin () ' value= ' Get Authenticode" type= "button" > </li></ul>
<script src= "js/jquery.js" ></script><script> function Duanxin () {//Get phone ID var iphone = $ (" #regi_mobile "). Val (); $.ajax ({ URL: ' Registers ', data: {' iphone ': iphone}, type: ' GET ', dataType: ' Json ', success: Function (msg) { if (msg[' stat '] = = ') { alert (' SMS sent successfully '); } else { alert (' message sent failed ')} } }); } </script>
2. Routing
Route::any (' registers ', ' [email protected] ');
3. Enter the controller
Public Function Logindo () {$iphone = $_get[' iphone ']; $code = rand (1000, 9999); Setcookie (' Code ', $code, Time () + 600);//change the URL address to yourself, and put the cell phone number and information template in the line $url = ' http://api.sms.cn/sms/?=send&uid= Xxx&pwd=61dfa5a45c06bf691767d35bcb197595&template=384859&mobile= '. $iphone. ' &content={' code ': '. $code. '} ' $data = Array (); $method = ' GET '; $res = $this->curlpost ($url, $data, $method); echo $res;} /*curlpost value */public function Curlpost ($url, $data, $method) {$ch = Curl_init ();//1. Initialize curl_setopt ($ch, Curlopt_ur L, $url); 2. Request Address curl_setopt ($ch, Curlopt_customrequest, $method)//3. Request method//4. The parameters are as follows curl_setopt ($ch, Curlopt_ssl_verifypeer, false);//https curl_setopt ($ch, Curlopt_ssl_verifyhost, false); curl_setopt ($ch, Curlopt_useragent, ' mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0);//Analog Browser curl_setopt ($ch, curlopt_followlocation, 1); curl_setopt ($ch, Curlopt_autoreferer, 1); curl_setopt ($ch, Curlopt_httpheader, Array (' ACCEPT-ENcoding:gzip, deflate '));//gzip extract Content curl_setopt ($ch, curlopt_encoding, ' gzip,deflate '); if ($method = = "POST") {//5.post mode when adding data curl_setopt ($ch, Curlopt_postfields, $data); } curl_setopt ($ch, Curlopt_returntransfer, true); $tmpInfo = curl_exec ($ch);//6. Execute if (Curl_errno ($ch)) {//7. If there is an error, return Curl_error ($ch); } curl_close ($ch);//8. Close the return $tmpInfo;}
4. That's it. Everybody, just test it!
Laravel Frame mobile phone to send verification code