騰訊云短信(Short Message Service,SMS)沉淀騰訊十多年短信服務技術和經驗,為 QQ、微信等億級平臺和10萬+客戶提供國內短信、語音短信與國際短信服務。國內短信驗證秒級觸達、99%到達率;語音短信提供語音專線與企業專屬碼號服務,支持大容量、高并發處理;國際短信覆蓋全球200+國家/地區,穩定可靠。騰訊云短信旨在幫助廣大開發者快速靈活接入高質量的文本、語音與國際短信服務。
很多客戶說用到騰訊云的短信接口,官方有SDK有JAVA版、PHP版、Python版、C#版和Node.js版,但唯獨沒有ASP版本的demo,故寫了一個關于騰訊云短信接口ASP版的接口程序,有需要可以聯系我!
部分代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<script language="jscript" runat="server">
Array.prototype.get = function(x) {
return this[x];
};
function parseJSON(strJSON) {
return eval("(" + strJSON + ")");
}
</script>
<%
Session.CodePage=65001
Response.charset = "utf-8"
%>
<!--#include file="sha.asp"-->
<%
'時間戳
Function ToUnixTime(strTime, intTimeZone)
If IsEmpty(strTime) Or Not IsDate(strTime) Then strTime = Now
If IsEmpty(intTimeZone) Or Not IsNumeric(intTimeZone) Then intTimeZone = 0
ToUnixTime = DateAdd("h", - intTimeZone, strTime)
ToUnixTime = DateDiff("s", "1970-1-1 0:0:0", ToUnixTime)
End Function
Function CreateOrderNo()
Dim yy,mm,dd,h,m,s,srnd
yy=year(now())
mm=right("0"&month(now()),2)
dd=right("0"&day(now()),2)
h=right("0"&hour(now()),2)
m=right("0"&Minute(now()),2)
s=right("0"&Second(now()),2)
Randomize
srnd=Right("0000"&int(Rnd*(100000)) +1,4)
CreateOrderNo=yy&mm&dd&h&m&s&srnd
End Function
suijishu=CreateOrderNo()
shijianchuo=ToUnixTime(now(), +8)
dianhua="15131557515"
sig=sha256("appkey=d917b19b28e09eda6d09c8a4a226b693&random="&suijishu&"&time="&shijianchuo&"&mobile="&dianhua&"")
On error resume next
Function GetBody(ips)
Set https = Server.CreateObject("MSXML2.XMLHTTP")
With https
.Open "Post", "https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400308056&random="&suijishu&"", False
.setRequestHeader "Content-Type","application/x-www-form-urlencoded;charset=utf-8"
.Send ips
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"utf-8")
Set https = Nothing
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
jsonok=GetBody("{""ext"": """", ""extend"": """",""params"": [""4567""],""sig"":"""&sig&""",""sign"": ""同心工貿"",""tel"": {""mobile"": """&dianhua&""",""nationcode"":""86""},""time"": """&shijianchuo&""",""tpl_id"": 528700}")
Set obj = parseJSON(jsonok)
Response.Write "原JSON字符串是:<br>"
Response.Write jsonok
Response.Write "<hr>"
Response.Write "result=" & obj.result & "<br />" '結果是aaa
Response.Write "errmsg=" & obj.errmsg & "<br />" '結果是bb
Response.Write "sid=" & obj.sid& "<br />" '結果是3
Response.Write "fee=" & obj.fee& "<br />" '結果是item0
Set obj = Nothing
%>