asp怎么调用Http短信接口呢?

n_e_e_d 2013-05-27 02:35:44
现在有一个http短信接口:http://sdk.kuai-xin.com:8888/sms.aspx?action=send&userid=12&account=账号&password=密码&mobile=15023239810,13527576163&content=内容&sendTime=

在asp里要如何调用这个短信接口呢?以前没接触过asp求大家指点下,帮忙给个详细的代码,谢谢了!
...全文
594 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lenece2013 2014-01-10
  • 打赏
  • 举报
回复
无账号
u011527752 2013-11-24
  • 打赏
  • 举报
回复
引用 1 楼 chinmo 的回复:
Function getHTTPPage(url)
Dim Http
Set Http = Server.CreateObject("MSXML2.XMLHTTP")
Http.Open "GET", url, False
Http.send()
If Http.readystate <> 4 Then
Exit Function
End If
getHTTPPage = BytesToBstr(Http.responseBody, "GB2312")
Set Http = Nothing
If Err.Number <> 0 Then Err.Clear
End Function

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

response.write getHTTPPage("http://sdk.kuai-xin.com:8888/sms.aspx?action=send&userid=12&account=账号&password=密码&mobile=15023239810,13527576163&content=内容&sendTime=")
直接传递那个网址进去就可以了
版主,我也遇到这个问题了, 能否帮助处理一下阿。 谢谢版主
n_e_e_d 2013-05-27
  • 打赏
  • 举报
回复
谢谢你了,已经做完了!
  • 打赏
  • 举报
回复
当然,你的是返回xml格式的,你可以直接
set xmlhttp=Server.CreateObject("MSXML2.XMLHTTP")
URL="http://sdk.kuai-xin.com:8888/sms.aspx?action=send&userid=12&account=账号&password=密码&mobile=15023239810,13527576163&content=内容&sendTime="
xmlhttp.open "POST",URL, False
xmlhttp.send 
       if xmlhttp.readyState = 4 then
     Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
     xmlDoc.loadXML(xmlhttp.responseText)
    Set item=xmlDoc.getElementsByTagName("returnsms")
    For i=0 To (item.Length-1)
     Set returnstatus=item.Item(i).getElementsByTagName("returnstatus")
     Set message=item.Item(i).getElementsByTagName("message")
     Response.Write returnstatus.Item(0).Text
     Response.Write message.Item(0).Text
     
    Next    
     end if
end if
自己调试吧
  • 打赏
  • 举报
回复
他返回来的值是xml格式的,你转换为xml的就可以使用xml的直接获取了
n_e_e_d 2013-05-27
  • 打赏
  • 举报
回复
太感谢你了!我问一下,他这短信接口的返回值是
<?xml version="1.0" encoding="utf-8" ?>
<returnsms>
<returnstatus>status</returnstatus> ---------- 返回状态值:成功返回Success 失败返回:Faild
<message>message</message> ---------- 返回信息:见下表
<remainpoint> remainpoint</remainpoint> ---------- 返回余额

<taskID>taskID</taskID>? -----------? 返回本次任务的序列ID
<successCounts>successCounts</successCounts> --成功短信数:当成功后返回提交成功短信数
</returnsms>
,我在网页上输出的结果为
,我该怎么提取出来里面的值分别用变量接收呢?比如a=Success b=ok
谢谢帮忙!
  • 打赏
  • 举报
回复
Function getHTTPPage(url)
Dim Http
Set Http = Server.CreateObject("MSXML2.XMLHTTP")
Http.Open "GET", url, False
Http.send()
If Http.readystate <> 4 Then
Exit Function
End If
getHTTPPage = BytesToBstr(Http.responseBody, "GB2312")
Set Http = Nothing
If Err.Number <> 0 Then Err.Clear
End Function

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

response.write getHTTPPage("http://sdk.kuai-xin.com:8888/sms.aspx?action=send&userid=12&account=账号&password=密码&mobile=15023239810,13527576163&content=内容&sendTime=")
直接传递那个网址进去就可以了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧