ASP via HTTP Call verification code SMS Interface source code

Source: Internet
Author: User

Through the Verification code SMS HTTP call interface, you can quickly in the website or the app to integrate mobile phone authentication and order notification class SMS function, the source code is just the core, specific to your actual needs to expand.

The following is the code for UTF-8 encoding ==================================================================<% @LANGUAGE = "VBSCRIPT" Codepage= "65001"%><%function Post (url,data) Dim Https Set Https=server.createobject ("MSXML2. XMLHTTP ") Https.open" POST ", Url,falsehttps.setrequestheader" Content-type "," application/x-www-form-urlencoded " Https.send dataif https.readystate=4 Thendim objstream Set objstream = Server.CreateObject ("ADODB.stream") objstream. Type = 1objstream. Mode =3objstream. Openobjstream.write Https.responseBodyobjstream.Position = 0objstream. Type = 2objstream. Charset = "Utf-8" Post = objstream. Readtextobjstream.closeset objstream = NothingSet https=nothingend ifend Functiondim target,post_datatarget = "/http/ 106.ihuyi.com/webservice/sms.php?method=submit "Post_data =" account= user name &password= password &mobile= mobile phone number & Content= "&server.urlencode (" Your Verification code is: 4526.) Please do not divulge the verification code to other people. ") Response. Write (Post (Target,post_data)) '//Please parse the string returned by post (Target,post_data) and implement your own logic%> the following is GBK encoded code ==================== ==============================================<meta http-equiv= "Content-type" content= "text/html;   CHARSET=GBK "/><% @LANGUAGE =" VBSCRIPT "codepage=" 936 "%><% ' asp UTF ext GB2312  The ASP code function UTF2GB (UTFSTR) for dig=1 to Len (utfstr) that converts UTF8 encoded text to GB encoded text if UTF8 encoded text is converted by% if mid (utfstr,dig,1) = "%"        Then ' UTF8 encoded text greater than 8 converted to kanji if Len (utfstr) >= dig+8 then Gbstr=gbstr & Convchinese (Mid (utfstr,dig,9)) Dig=dig+8 Else Gbstr=gbstr & Mid (utfstr,dig,1) End If Else Gbstr=gbstr & Mid (Utfstr,di g,1) End Ifnextutf2gb=gbstrend function ' GB2312 to UTF8 ASP code converts GB encoded text to UTF8 encoded text function toUTF8 (szinput) Dim WCh, Uch, Szret Dim x Dim NAsc, NAsc2, nAsc3 ' If the input parameter is empty, exit the function if Szinput = "then toUTF8 = Szinput E          xit function End If ' start conversion for x = 1 to Len (szinput) ' using the Mid function to split GB encoded text WCH = Mid (Szinput, X, 1) ' Use the ASCW function to return the Unicode character code for each GB encoded text ' NOTE: The ASC function returns an ANSI character code, note the difference NASC = AScW (WCH) if NASC < 0 Then nAsc = nAsc + 65536 If (NASC and &hff80) = 0 Then Szret =  Szret & WCh Else If (NASC and &hf000) = 0 Then uch = "%" & Hex (((NASC \ 2                ^ 6) Or &hc0) & Hex (NASC and &h3f Or &h80) Szret = Szret & Uch Else  ' GB encoded text Unicode character code between 0800-FFFF with three-byte template uch = "%" & Hex ((NASC \ 2 ^) Or &he0) &                             "%" & _ Hex ((NASC \ 2 ^ 6) and &h3f Or &h80) & "%" & _     Hex (NASC and &h3f Or &h80) Szret = szret & uch End if End If       Next toUTF8 = szretend function ' binary conversion to 16 binary ASP code Function C2TO16 (x) i=1 for I=1 to Len (x) Step 4 C2to16=c2to16 & Hex (C2to10 (Mid (x,i,4)) NextEnd function ' binary conversion to decimal ASP code function c2to10 (x) c2to10=0 if x= "0"      Then Exit functionI=0 for i= 0 to Len (x)-1 if Mid (X,len (x)-i,1) = "1" and then c2to10=c2to10+2^ (i) NextEnd function ' 16 binary converted to binary ASP code F  Unction C16to2 (x) i=0 for I=1 to Len (Trim (x)) tempstr= C10to2 (CInt (int ("&h" & Mid (x,i,1)))) While Len (tempstr) <4 tempstr= "0" & TempStr loop C16to2=c16to2 & TempStr NextEnd Functi         Onfunction C10to2 (x) mysign=sgn (x) x=abs (x) Digs=1 do if X<2^digs then exit do else          Digs=digs+1 End If Loop tempnum=x i=0 for I=digs to 1 step-1 if tempnum>=2^ (i-1) Then    tempnum=tempnum-2^ (i-1) C10to2=c10to2 & "1" Else C10to2=c10to2 & "0" End If Next if Mysign=-1 then C10to2= "-" & c10to2end function ' UTF8 encoded text will be converted to Kanji function Convchinese (x) A=split (Mid (x,2), "%     ") i=0 j=0 for i=0 to UBound (a) A (i) =c16to2 (A (i)) next for I=0 to UBound (a)-1 digs=instr (A (i)," 0 ") Unicode= "" For J=1 To DigS-1 if J=1 then a (i) =right (A (i), Len (A (i))-digs) Unicode=unicode & A (i) Else I=i+1 A (i) =right (A (i), Len (A (i))-2) Unicode=unicode & A (i) End If Next If Len (C2to16 ( Unicode)) =4 then Convchinese=convchinese & ChrW (int ("&h" & C2to16 (Unicode))) Else Convchines  E=convchinese & chr (int ("&h" & C2to16 (Unicode))) End If NextEnd function ' GB2312 Chinese to Unicode ' ASP code Convert GB encoded text to Unicode encoded text function Chinese2unicode (str) Dim i Dim Str_one Dim Str_unicode If (IsNull (str)) then ex It function End If for I=1 to Len (Str) Str_one=mid (str,i,1) STR_UNICODE=STR_UNICODE&AMP;CHR (str_unicod)     E=STR_UNICODE&AMP;CHR (STR_UNICODE=STR_UNICODE&AMP;CHR) str_unicode=str_unicode& Hex (AscW (Str_one)) STR_UNICODE=STR_UNICODE&AMP;CHR next chinese2unicode=str_unicodeend function ' URL address code decoding functions UrlDecode (EnS TR) Dim Destrdim C,i,vdestR= "" For I=1 to Len (enstr) C=mid (enstr,i,1) if c= "%" then V=eval ("&h" +mid (enstr,i+1,2)) if v<128 then       DESTR=DESTR&AMP;CHR (v) i=i+2 else if Isvalidhex (Mid (enstr,i,3)) then if Isvalidhex (Mid (enstr,i+3,3)) Then V=eval ("&h" +mid (enstr,i+1,2) +mid (enstr,i+4,2)) DESTR=DESTR&AMP;CHR (v) i=i+5 else V=eval ("      &h "+mid (enstr,i+1,2) +cstr (Hex (ASC (enstr,i+3,1)))) DESTR=DESTR&AMP;CHR (v) i=i+3 End If Else    Destr=destr&c End If Else if c= "+" then destr=destr& "" Else destr=destr&c End If End Ifnexturldecode=destrend function ' Determines whether a valid hexadecimal code function isvalidhex (str) Dim cisvalidhex=truestr=ucase (str   If Len (str) <>3 then Isvalidhex=false:exit functionif Left (str,1) <> '% ' then isvalidhex=false:exit function    C=mid (str,2,1) If Not (((c>= ' 0 ") and (c<=" 9 ") or ((c>=" A ") and (c<=" Z ")) then Isvalidhex=false:exit function C=mid (str,3,1) if not ((c>= "0") and (c<= "9")) or ((c>= "A") and (c<= "Z"))) then Isvalidhex=false:exit functionend functionfunction Post (url,data) Dim Httpsset Https=server.createobject ("MSXML2. XMLHTTP ") Https.open" POST ", Url,falsehttps.setrequestheader" Content-type "," application/x-www-form-urlencoded " Https.send dataif https.readystate=4 thendim Objstreamset objstream = Server.CreateObject ("ADODB.stream") objstream. Type = 1objstream. Mode =3objstream. Openobjstream.write Https.responseBodyobjstream.Position = 0objstream. Type = 2objstream. Charset = "Utf-8" Post = objstream. Readtextobjstream.closeset objstream = NothingSet https=nothingend ifend Functiondim target,post_data,contenttarget = " Http://106.ihuyi.com/webservice/sms.php?method=Submit "content = ToUTF8 (" Your Verification code is: 4526.) Please do not divulge the verification code to other people. ") Post_data =" account= user name &password= password &mobile= mobile phone number &content= "&content ' Response.Write toUTF8 (" SMS Test " ) Response. Write (UTF2GB (Target,post_data)) "//Please parse the string returned by the post (Target,post_data) and implement your own logic%>
self-application account address:http://www.ihuyi.com/product.php
Full interface file address:Http://www.ihuyi.com/upload/file/cu-fa-jie-kou.rar 

ASP via HTTP Call verification code SMS Interface source 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.