记录一下 asp调用短信接口的例子,可以解决80%的调用短信接口产生的乱码问题.
以下代码只是简单的调用,需要根据具体的项目 做相应的修改
<%
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
调用短信接口网址官方网站:http://www.56dxw.com
Function SendSms(smsMob,smsText)
'response.Write(smsMob)
'response.End()
SmsServer="http://jiekou.56dxw.com/sms/HttpInterface.aspx?"
userid="60"
username1="test1"
userpwd="qwqwqw"
usersms="1061"
SenData=SmsServer&"comid="&userid&"&username="&username1&"&userpwd="&userpwd&"&
handtel="&smsMob&"&sendcontent="&smsText&"&sendtime=&smsnumber="&usersmsqwe=getHTTPPage(SenData)
'response.Write(qwe)
If qwe = "1" then '发送成功
Response.Write("成功了")
Else '发送失败
Response.Write("失败了,请联系管理员")
End if
End Function
%>