太阳集团81068网址(中国)有限公司

太阳集团81068网址 > 帮助中心 > 代码示例 > ASP

ASP DEMO


<%@  language="VBScript" %><%
发送短信
Function SendSms(sname,spwd,smobiles,scontent)
    dim ht,pos
    set ht=Server.createobject("微软.XMLHTTP") 
    ht.open "GET","http://api.sms1086.com/api/Send.aspx?username="&Server.URLEncode(sname)&"&password="&Server.URLEncode(spwd)&"&mobiles="&smobiles&"&content="&Server.URLEncode(scontent)&"",false
    ht.setRequestHeader "Content-type:", "text/xml;charset=GB2312"
    ht.send
    ret=urldecode(ht.ResponseText)
    response.Write ret
    response.End
    set ht=nothing
    pos = InStr(ret,"result=0")
    if pos > 0 then
        SendSms = true
    else
        SendSms = false
    end if
End Function

修改密码
function chgpwd(sname,spwd,new_password)
    dim ht
    set ht=Server.createobject("微软.XMLHTTP") 
    ht.open "GET","http://api.sms1086.com/api/Send.aspx?username="&Server.URLEncode(sname)&"&password="&Server.URLEncode(spwd)&"&newpws="&Server.URLEncode(new_password)&"",false
    ht.setRequestHeader "Content-type:", "text/xml;charset=GB2312"
    ht.send
    ret=urldecode(ht.ResponseText)
    set ht=nothing
    chgpwd=true
end function

查询余额
function Query(sname,spwd)
    dim ht
    set ht=Server.createobject("微软.XMLHTTP") 
    ht.open "GET","http://api.sms1086.com/api/Send.aspx?username="&Server.URLEncode(sname)&"&password="&Server.URLEncode(spwd)&"",false
    ht.setRequestHeader "Content-type:", "text/xml;charset=GB2312"
    ht.send
    ret=urldecode(ht.ResponseText)
    set ht=nothing
    Query=true
end function

url编码
function urldecode(encodestr)    
newstr=""    
havechar=false    
lastchar=""    
for i=1 to len(encodestr)    
char_c=mid(encodestr,i,1)    
if char_c="+" then    
newstr=newstr & " "    
elseif char_c="%" then    
next_1_c=mid(encodestr,i+1,2)    
next_1_num=cint("&H" & next_1_c)    
if havechar then    
havechar=false    
newstr=newstr & chr(cint("&H" & lastchar & next_1_c))    
else    
if abs(next_1_num)<=127 then    
newstr=newstr & chr(next_1_num)    
else    
havechar=true    
lastchar=next_1_c    
end if    
end if    
i=i+2    
else    
newstr=newstr & char_c    
end if    
next    
urldecode=newstr    
end function   
function urldecode(encodestr) 
newstr="" 
havechar=false 
lastchar="" 
for i=1 to len(encodestr) 
char_c=mid(encodestr,i,1) 
if char_c="+" then 
newstr=newstr & " " 
elseif char_c="%" then 
next_1_c=mid(encodestr,i+1,2) 
next_1_num=cint("&H" & next_1_c) 
if havechar then 
havechar=false 
newstr=newstr & chr(cint("&H" & lastchar & next_1_c)) 
else 
if abs(next_1_num)<=127 then 
newstr=newstr & chr(next_1_num) 
else 
havechar=true 
lastchar=next_1_c 
end if 
end if 
i=i+2 
else 
newstr=newstr & char_c 
end if 
next 
urldecode=newstr 
end function 

  dim sname,spwd,smobiles,scontent
  sname=trim(request.form("username")) 
  spwd =trim(request.form("pwd"))  
  smobiles=trim(request.form("mobiles"))  
  scontent=trim(request.form("contents")) 

if SendSms(sname,spwd,smobiles,scontent)then 
   response.write "发送成功"
else
    response.write "发送失败"
end if

%>

太阳集团81068网址|太阳集团81068网址

XML 地图 | Sitemap 地图