短信发送&余额获取
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="base64.asp"-->
<%
response.contenttype = "text/html;charset=utf-8"
'短信接口的 Authorization 认证
function request_auth(method,url,auth,data,cset)
dim xml
set xml = server.createobject("Msxml2.ServerXMLHTTP.3.0")
xml.open method,url,false
xml.setrequestheader "Authorization",auth
if method = "POST" then
xml.setrequestheader "content-length",len(data)
xml.setrequestheader "content-type","application/x-www-form-urlencoded"
xml.send(data)
else
xml.send()
end if
on error resume next
request_auth = xml.responseText
if err then
err.clear
request_auth = bytetostr(xml.responseBody,cset)
end if
set xml = nothing
end function
'ByteToStr
function bytetostr(vin,cset)
dim bs,sr
set bs = server.createObject("adodb.stream")
bs.type = 2
bs.open
bs.writetext vin
bs.position = 0
bs.charset = cset
bs.position = 2
sr = bs.readtext
bs.close
set bs = nothing
bytetostr = sr
end function
'API & KEY
api_username = "api"
api_password = "key-XXXXXXXXXXXXXXXXXXXXXXXX"
api_auth = "Basic " & encode64(api_username & ":" & api_password)
'短信发送
sms_mobile = "13936628410"
sms_message = "测试验证码是654321【luosimao】"
api_urlsend = "http://sms-api.luosimao.com/v1/send.json"
api_data = "mobile=" & sms_mobile & "&message=" + sms_message
api_method = "POST"
response.write "发送短信:" & request_auth(api_method,api_urlsend,api_auth,api_data,api_charset)
response.write "<hr>"
'余额状态
api_urlstatus = "http://sms-api.luosimao.com/v1/status.json"
api_method = "GET"
api_charset = "utf-8"
api_data = ""
response.write "短信余额:" & request_auth(api_method,api_urlstatus,api_auth,api_data,api_charset)
response.write "<hr>"
%>
短信语音&余额获取
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="base64.asp"-->
<%
response.contenttype = "text/html;charset=utf-8"
'短信接口的 Authorization 认证
function request_auth(method,url,auth,data,cset)
dim xml
set xml = server.createobject("Msxml2.ServerXMLHTTP.3.0")
xml.open method,url,false
xml.setrequestheader "Authorization",auth
if method = "POST" then
xml.setrequestheader "content-length",len(data)
xml.setrequestheader "content-type","application/x-www-form-urlencoded"
xml.send(data)
else
xml.send()
end if
on error resume next
request_auth = xml.responseText
if err then
err.clear
request_auth = bytetostr(xml.responseBody,cset)
end if
set xml = nothing
end function
'ByteToStr
function bytetostr(vin,cset)
dim bs,sr
set bs = server.createObject("adodb.stream")
bs.type = 2
bs.open
bs.writetext vin
bs.position = 0
bs.charset = cset
bs.position = 2
sr = bs.readtext
bs.close
set bs = nothing
bytetostr = sr
end function
'API & KEY
api_username = "api"
api_password = "key-XXXXXXXXXXXXXXXXXXXXXXXX"
api_auth = "Basic " & encode64(api_username & ":" & api_password)
'语音发送
sms_mobile = "13936628411"
sms_code = "123456"
api_urlsend = "http://voice-api.luosimao.com/v1/verify.json"
api_data = "mobile=" & sms_mobile & "&code=" + sms_code
api_method = "POST"
response.write "发送短信:" & request_auth(api_method,api_urlsend,api_auth,api_data,api_charset)
response.write "<hr>"
'余额状态
api_urlstatus = "http://voice-api.luosimao.com/v1/status.json"
api_method = "GET"
api_charset = "utf-8"
api_data = ""
response.write "短信余额:" & request_auth(api_method,api_urlstatus,api_auth,api_data,api_charset)
response.write "<hr>"
%>