. NET implementation of SMS verification code

Source: Internet
Author: User

Interface type: Mutual billion wireless trigger SMS interface, support to send verification code SMS, order notification SMS and so on.

Account Registration: Please open an account via this address http://sms.ihuyi.com/register.html

Can only be tested with:

Implementing the registration page

<script type= "Text/javascript" > Function Get_mobile_code () {$.get (' post.aspx ', {Mobile:jQuery.trim ($ (' #            Mobile '). Val ())}, function (msg) {alert (Jquery.trim (unescape (msg)));            if (msg = = ' Submit Success ') {remaintime ();    }        });    };    var itime = 59;    var account;        function Remaintime () {document.getElementById (' zphone '). Disabled = true;        var isecond, Ssecond = "", stime = "";            if (itime >= 0) {Isecond = parseint (itime% 60); Iminute = parseint (ITIME/60) if (isecond >= 0) {if (Iminute > 0) {s                Second = Iminute + "min" + Isecond + "second";                } else {Ssecond = Isecond + "SEC";            }} stime = Ssecond;                if (itime = = 0) {cleartimeout (account);                stime = ' Get phone verification code ';                Itime = 59; document.getElementById (' ZPhone '). Disabled = false;                } else {account = SetTimeout ("Remaintime ()", 1000);            Itime = iTime-1;        }} else {stime = ' no countdown ';    } document.getElementById (' Zphone '). Value = Stime; }</script>

  

<form action=""Method="Post"Name="Formuser"onsubmit="return register ();"> <table width="100%"Border="0"align=" Left"cellpadding="5"cellspacing="3"> <tr> <td align=" Right"> Mobile <td> <input id="Mobile"Name="Extend_field5"Type="text"Size=" -" class="INPUTBG"/><span style="Color: #FF0000"> *</span> <input id="Zphone"Type="Button"Value="Send phone verification code"onclick="Get_mobile_code ();"></td> </tr> <tr> <td align=" Right"> Verification Code </td> <td><input type="text"Size="8"Name="Captcha" class="INPUTBG"/></td> </tr> </table></form>

Background code

  Public Static stringPostURL = configurationmanager.appsettings["WEBREFERENCE.SERVICE.POSTURL"]; protected voidPage_Load (Objectsender, EventArgs e) {            stringAccount ="C23795760";//User name is login User Center--Verification code, notification SMS--account and signature settings->apiid            stringPassword ="B79bc3ff3985ea849964fb7a5fdf78ea";//Password is please login User Center--Verification code, notification SMS--account and signature settings->apikey            stringMobile = request.querystring["Mobile"]; Random rad=NewRandom (); intMobile_code = rad. Next ( +,10000); stringContent ="I'm here to test. Don't be afraid. ZMD:"+ Mobile_code +". Please do not divulge the verification code to other people. "; //session["mobile" = mobile; //session["Mobile_code"] = Mobile_code;            stringPOSTSTRTPL ="Account={0}&password={1}&mobile={2}&content={3}"; UTF8Encoding encoding=Newutf8encoding (); byte[] postdata = encoding. GetBytes (string.            Format (POSTSTRTPL, account, password, mobile, content)); HttpWebRequest Myrequest=(HttpWebRequest) webrequest.create (PostURL); Myrequest.method="POST"; Myrequest.contenttype="application/x-www-form-urlencoded"; Myrequest.contentlength=postdata.length; Stream Newstream=Myrequest.getrequeststream (); //Send the data.Newstream.write (PostData,0, postdata.length);            Newstream.flush ();            Newstream.close (); HttpWebResponse Myresponse=(HttpWebResponse) myrequest.getresponse (); if(Myresponse.statuscode = =Httpstatuscode.ok) {StreamReader reader=NewStreamReader (Myresponse.getresponsestream (), Encoding.UTF8); //Response.Write (reader. ReadToEnd ());                stringres =Reader.                ReadToEnd (); intLen1 = Res. IndexOf ("</code>"); intLen2 = Res. IndexOf ("<code>"); stringCode = Res. Substring ((Len2 +6), (Len1-len2-6)); //Response.Write (code);                intLen3 = Res. IndexOf ("</msg>"); intLen4 = Res. IndexOf ("<msg>"); stringmsg = Res. Substring ((Len4 +5), (Len3-len4-5));                Response.Write (msg);            Response.End (); }            Else            {                //Access failed            }        }

Web.confg

<appSettings>    <add key="WebReference.Service.PostUrl" value= " Http://106.ihuyi.cn/webservice/sms.php?method=Submit "/>    <add key="webreference.sms" value="/http/ 106.ihuyi.cn/webservice/sms.php?smsservice"/>  </appSettings>

. NET implementation of SMS verification code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.