I use a name is called SMS Bao Application, the new registered users can free 3 Test text messages, found a bug, the same phone can be unlimited registration, play or can be.
Inside the SMS Interface code what information is not, feel not very clear, oneself test again, can use, direct call on can, if you want to use the project also have a lot of details to deal with, such as set a verification code survival time, and click the button every minute to press once, Also have to judge this user to send the text message another user can use, later have time to continue to do, now first to a simple version of
Views Layer View
1<!doctype html>234<meta charset= "UTF-8" >5<title>ajax No refresh upload </title>67<script type= "Text/javascript" src= "__public__/js/jquery-1.10.2.min.js" ></script>8 9<body>Ten<div> OnePlease enter phone number: <input type= "text" name= "Phone"class= "Phone" > A</div> -<div> -<a href= "javascript:;"class= "Butphone" > Click to get SMS Verification code </a> the</div> -</body> -<script type= "Text/javascript" > - +$ ('. Butphone '). Click (function(){ - + varPhone = $ ('. Phone '). Val ();//Mobile phone number A at$.Post ( - -"{: U (' Smsbao ')}",//method of passing - -{Phone1:phone},//Parameters - in function(data) { - to if(data = = ' 1 ')){ +Alert (' Input box cannot be empty '); -}Else if(data = = ' 2 ')){ theAlert (' Input value is not a number '); *}Else{ $ alert (data);Panax Notoginseng } - the}, +' JSON ' A ) the }) +</script> - $
Controller Layer Controllers
1<?PHP2 namespace Home\controller;3 UseThink\controller;4 classIndexcontrollerextendsController5 {6 //View7 Public functionindex ()8 {9 $this-display ();Ten } One A //SMS Interface - Public functionSmsbao () - { the $phonenum=Trim(I (' post.phone1 '));//the parameters received - - //First judge that the phone is not empty - if(Empty($phonenum) ){ + - $this->ajaxreturn (' 1 '); + } A at //determine whether a number - $boolphone=Is_numeric($phonenum); - - if($boolphone){ - - $statusStr=Array( in"0" = "SMS sent successfully", -"-1" = "parameter not complete", to"-2" + "server space not supported, please confirm support curl or fsocket, contact your space provider to resolve or change the space!" ", +"+" = "Password Error", -"+" = "Account Not Present", the"A" and "Not Enough balance", *"A" and "Account expired" $"+" = "IP address limit",Panax Notoginseng"+" + "content contains sensitive words" - ); the $num=Rand(100000, 999999);//Set random number + A Setcookie("Numset",$num);//put the value into a cookie and close the browser to clear the cookie; the + $smsapi= "http://api.smsbao.com/"; - $ $user= "asdf75054138";//SMS Platform Account $ - $pass=MD5("asdf75054138");//SMS Platform Password - the $content= "[Bug], verification from four Musketeers, Verification code:".$num;//to send the message content, casually set - Wuyi $phone=$phonenum;//mobile phone number to send a text message the - $sendurl=$smsapi." Sms?u= ".$user." &p= ".$pass." &m= ".$phone." &c= ".UrlEncode($content);//Fixed Format Wu - $result=file_get_contents($sendurl);//Fixed Format About $ $this->ajaxreturn ($statusStr[$result] );//whether the text message was sent successfully - -}Else{ - $this->ajaxreturn (' 2 ' ); A } + the } -}
Various:
Attachment
SMS Bao url:http://www.cocsms.com/
Direct registration of an account, pop let you use a text message test do not test, or you will lose a piece.
thinkphp frame--SMS Interface Verification code