asp短信接口源码 比较简单但也挺实用用的(两个写法)
程序员文章站
2022-04-14 18:57:19
写法一: 复制代码 代码如下: <% sub sendsms(mobile,msg) '如需要发送多个手机号,请自动循环,多个手机号之间用“,”分隔,最后手机号码后不...
写法一:
<%
sub sendsms(mobile,msg)
'如需要发送多个手机号,请自动循环,多个手机号之间用“,”分隔,最后手机号码后不加,号
'或调用我们 httpinterfacemore.aspx 接口,后跟参数一样或调用我们的webservers接口
dim userid,password,username,sms,status
dim xmlobj,httpsendurl
'请添写您的账号密码
sms="平台"
username="用户名"
userid = "企业id"
password = "密码"
请联系我们索取免费测试帐号
httpsendurl="http://jiekou.56dxw.com/sms/httpinterface.aspx?
comid="&userid&"&username="&username&"&userpwd="&password&"&handtel="&mobile&"
&sendcontent="&server.urlencode(msg)&"&sendtime=&smsnumber="&sms
set xmlobj = server.createobject("microsoft.xmlhttp")
xmlobj.open "post",httpsendurl,false
xmlobj.send()
status = xmlobj.responsetext
set xmlobj = nothing
if status = "1" then '发送成功
response.write "<br><br>返回状态码:"&status&" 发送状态:发送成功! <a
href=""javascript:history.back();"">返回发送页面</a>"
else '发送失败
response.write "<br><br>返回状态码:"&status&" 发送状态:发送失败! <a
href=""javascript:history.back();"">返回发送页面</a>"
end if
end sub
%>
写法二
<%
function sendsms(username, userpass, dstmobile, smsmsg)
dim http,msg,strurl,rndnumber
set http = server.createobject("microsoft.xmlhttp")
strurl="http://jiekou.56dxw.com/sms/httpinterface.aspx?comid=121&username="&smsname&"&userpwd="&smspw&"
&sendtime=&smsnumber=1065&handtel="&dstmobile&"&sendcontent="&server.urlencode(smsmsg)
http.open "get",strurl, false
http.setrequestheader "content-type:", "text/xml;charset=gb2312"
http.send
msg=http.responsetext
set http = nothing
'代表发送成功
if msg="1" then
sendsms="ok"
else
sendsms="err"
end if
end function
%>
复制代码 代码如下:
<%
sub sendsms(mobile,msg)
'如需要发送多个手机号,请自动循环,多个手机号之间用“,”分隔,最后手机号码后不加,号
'或调用我们 httpinterfacemore.aspx 接口,后跟参数一样或调用我们的webservers接口
dim userid,password,username,sms,status
dim xmlobj,httpsendurl
'请添写您的账号密码
sms="平台"
username="用户名"
userid = "企业id"
password = "密码"
请联系我们索取免费测试帐号
httpsendurl="http://jiekou.56dxw.com/sms/httpinterface.aspx?
comid="&userid&"&username="&username&"&userpwd="&password&"&handtel="&mobile&"
&sendcontent="&server.urlencode(msg)&"&sendtime=&smsnumber="&sms
set xmlobj = server.createobject("microsoft.xmlhttp")
xmlobj.open "post",httpsendurl,false
xmlobj.send()
status = xmlobj.responsetext
set xmlobj = nothing
if status = "1" then '发送成功
response.write "<br><br>返回状态码:"&status&" 发送状态:发送成功! <a
href=""javascript:history.back();"">返回发送页面</a>"
else '发送失败
response.write "<br><br>返回状态码:"&status&" 发送状态:发送失败! <a
href=""javascript:history.back();"">返回发送页面</a>"
end if
end sub
%>
写法二
复制代码 代码如下:
<%
function sendsms(username, userpass, dstmobile, smsmsg)
dim http,msg,strurl,rndnumber
set http = server.createobject("microsoft.xmlhttp")
strurl="http://jiekou.56dxw.com/sms/httpinterface.aspx?comid=121&username="&smsname&"&userpwd="&smspw&"
&sendtime=&smsnumber=1065&handtel="&dstmobile&"&sendcontent="&server.urlencode(smsmsg)
http.open "get",strurl, false
http.setrequestheader "content-type:", "text/xml;charset=gb2312"
http.send
msg=http.responsetext
set http = nothing
'代表发送成功
if msg="1" then
sendsms="ok"
else
sendsms="err"
end if
end function
%>