阿里云短信接口ASP版,调用SendSMS
- Public Function POPUrlEncode(ByVal UrlStr)
- Dim Str
- Str = Server.URLEncode(UrlStr)
- Str = Replace(Str,"%5F","_")
- Str = Replace(Str,"%2D","-")
- Str = Replace(Str,"%2E",".")
- Str = Replace(Str,"+","%20")
- Str = Replace(Str,"*","%2A")
- Str = Replace(Str,"%7E","~")
- POPUrlEncode = Str
- End Function
- Public Function SendSMS(ByVal AccessKeyId,ByVal AccessKeySecret,ByVal PhoneNumbers,ByVal SignName,ByVal TemplateCode,ByVal TemplateParam,ByVal OutId)
- Dim Domain,Timestamp,Format,SignatureMethod,SignatureVersion,SignatureNonce,Action,Version,RegionId
- Domain = "http://dysmsapi.aliyuncs.com/"
- Dim Times,NewTimes
- Times = Zasp.Times.ToUnixTime(Now(),0)
- NewTimes = Zasp.Times.UnixTimeTo(Times,-8)
- Timestamp = Year(NewTimes) & "-" & Right("0" & Month(NewTimes),2) & "-" & Right("0" & Day(NewTimes),2) & "T" & Right("0" & Hour(NewTimes),2) & ":" & Right("0" & Minute(NewTimes),2) & ":" & Right("0" & Second(NewTimes),2) & "Z"
- Format = "JSON"
- SignatureMethod = "HMAC-SHA1"
- SignatureVersion = "1.0"
- SignatureNonce = Zasp.Base.RndEChar(32,"U")
- Action = "SendSms"
- Version = "2017-05-25"
- RegionId = "cn-hangzhou"
- Dim DataTemp
- DataTemp = Array("AccessKeyId=" & POPUrlEncode(AccessKeyId) & "","Timestamp=" & POPUrlEncode(Timestamp) & "","Format=" & POPUrlEncode(Format) & "","SignatureMethod=" & POPUrlEncode(SignatureMethod) & "","SignatureVersion=" & POPUrlEncode(SignatureVersion) & "","SignatureNonce=" & POPUrlEncode(SignatureNonce) & "","Action=" & POPUrlEncode(Action) & "","Version=" & POPUrlEncode(Version) & "","RegionId=" & POPUrlEncode(RegionId) & "","PhoneNumbers=" & POPUrlEncode(PhoneNumbers) & "","SignName=" & POPUrlEncode(SignName) & "","TemplateCode=" & POPUrlEncode(TemplateCode) & "","TemplateParam=" & POPUrlEncode(TemplateParam) & "","OutId=" & POPUrlEncode(OutId))
- Data = Zasp.Base.SortPara(DataTemp,UBound(DataTemp),"&")
- Dim Sign
- Sign = "GET&" & POPUrlEncode("/") & "&" & POPUrlEncode(Data)
- Sign = POPUrlEncode(Zasp.Encrypt.HMACSHA1(Sign,AccessKeySecret & "&","Base64"))
- SendSMS = Zasp.XMLHTTP.GetHTTP(Domain & "?Signature=" & Sign & "&" & Data,"UTF-8")
- End Function
复制代码 |