RELATEED CONSULTING
相关咨询
马上在线沟通
服务时间:8:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏

技术支持

技术支持分类
短信接口之二次开发ASP接口
  • 作者:
  • 发表时间:2017-08-11 16:55
说明:
SmsSend.asp是封装的发送类,直接调用即可。具体指令参考《对外接口参数_下行.txt》
 
调用示例:
 
cmd = "1"
content = "短信内容"
mobile = "手机号码"
sendtime = "0"
Set sms = new SmsSend 
sms.cmd = cmd
'sms.content = content '短信内容
sms.mobile = mobile '手机号码
sms.sendtime = sendtime '发送时间
sms.getto '开始提交
page = sms.value '返回信息
Set sms = Nothing '释放对象
response.write (page)
------------------------------------------------------------------
<% 
Class SmsSend
'____________________
Private value_ '反回信息
Private src_ '提交的目标URL地址
Private userid_ '
Private password_ '密码,中英文及数字
Private account_ '用户名,中英文及数字
Private content_ '短信内容,中英文及数字
Private mobile_ '手机号码,用半角逗号(,)间隔
Private sendtime_ '定时发送时间,默认0,格式yyyymmddhhnnss,小于当前时间的立即发送
Private charset_ '
Private isGet_ '判断是否已经提交
Private strxml_ '
 
Public property let src(srcs) '赋值—短信内容
src_ = srcs
End Property
 
Public property let userid(userids) '赋值—短信内容
userid_ = userids
End Property
 
Public property let password(passwords) '赋值—短信内容
password_ = passwords
End Property
 
Public property let account(accounts) '赋值—短信内容
account_ = accounts
End Property
 
Public property let content(contents) '赋值—短信内容
content_ = contents
End Property
 
Public property let mobile(mobiles) '赋值—手机号码
mobile_ = mobiles
End Property
 
Public property let sendtime(sendtimes) '赋值—手机号码
sendtime_ = sendtimes
End Property
 
Public property let charset(charsets) '赋值—提交的目标URL地址/属性
charset_ = charsets
End property
 
Public property get value '返回值—应用类方法加工过的内容/属性
value = value_
End property
 
Public Property get Version
Version="短信发送类"
End Property
 
private Sub class_initialize()
value_ = ""
src_ = "http://客户端地址/sms.aspx"
userid_ = "12"
password_ = "123456"
account_="test"
content_ = ""
mobile_ = ""
sendtime_ = 0
charset_ = "gb2312"
isGet_ = False
End Sub
 
private Sub class_terminate()
End Sub
 
private Function BytesToBstr(body,Cset) '中文处理
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function
 
Public Sub getto() '窃取目标URL地址的HTML代码/方法
Dim Http
Set Http = Server.CreateObject("Msxml2.XMLHTTP.3.0")
If Err Then
Err.Clear
Set Http = Server.CreateObject("Msxml2.XMLHTTP")
If Err Then
Err.Clear
Set Http = Server.CreateObject("Microsoft.XMLHTTP")
If Err Then
Err.Clear
Rem 服务器不支持Msxml,本程序无法运行!
Exit Sub
End If
End If
End If
Http.Open "POST", src_, False
If action_ = 1 Or action_ = 2  Then
strxml_ = "action=send&userid="&userid_&"&account="&account_&"&password="&password_&"&action="&action_
Else
strxml_ = "action=send&userid="&userid_&"&account="&account_&"&password="&password_&"&content="&content_&"&mobile="&mobile_&"&sendtime="&sendtime_
End If
Http.SetRequestHeader "CONTENT-LENGTH ",len(strxml_)
Http.SetRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded"
Http.Send(strxml_)
If Http.Status<>200 Then
value_="sms error"
Exit Sub
End If
value_=BytesToBSTR(Http.responseBody,charset_)
isGet_= True
Set http=Nothing
If err.number<>0 Then err.Clear
 
Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(value_)
Set objNodes = objXML.getElementsByTagName("returnsms") 
Dim returnstatus
Dim remainpoint
Dim message
if not isNUll(objNodes(0)) then
returnstatus=Trim(objNodes(0).getAttribute("returnstatus"))
if returnstatus="Success" then
response.Write("提交成功")
else
 
response.Write("提交失败")
end if
end if
 
End Sub
 
End class
 
dim sendsms
Set sendsms = New SmsSend
call sendsms.getto()
Set sendsms=nothing
%>