查看: 58|回复: 2

[ASP函数] 阿里云短信接口ASP版

[复制链接]
天下第一 发表于 2024-11-13 15:23:28 | 显示全部楼层 |阅读模式
阿里云短信接口ASP版,调用SendSMS

  1.         Public Function POPUrlEncode(ByVal UrlStr)
  2.                 Dim Str
  3.                 Str = Server.URLEncode(UrlStr)
  4.                 Str = Replace(Str,"%5F","_")
  5.                 Str = Replace(Str,"%2D","-")
  6.                 Str = Replace(Str,"%2E",".")
  7.                 Str = Replace(Str,"+","%20")
  8.                 Str = Replace(Str,"*","%2A")
  9.                 Str = Replace(Str,"%7E","~")
  10.                 POPUrlEncode = Str
  11.         End Function

  12.         Public Function SendSMS(ByVal AccessKeyId,ByVal AccessKeySecret,ByVal PhoneNumbers,ByVal SignName,ByVal TemplateCode,ByVal TemplateParam,ByVal OutId)
  13.                 Dim Domain,Timestamp,Format,SignatureMethod,SignatureVersion,SignatureNonce,Action,Version,RegionId
  14.                 Domain = "http://dysmsapi.aliyuncs.com/"
  15.                 Dim Times,NewTimes
  16.                 Times = Zasp.Times.ToUnixTime(Now(),0)
  17.                 NewTimes = Zasp.Times.UnixTimeTo(Times,-8)
  18.                 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"
  19.                 Format = "JSON"
  20.                 SignatureMethod = "HMAC-SHA1"
  21.                 SignatureVersion = "1.0"
  22.                 SignatureNonce = Zasp.Base.RndEChar(32,"U")
  23.                 Action = "SendSms"
  24.                 Version = "2017-05-25"
  25.                 RegionId = "cn-hangzhou"
  26.                 Dim DataTemp
  27.                 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))
  28.                 Data = Zasp.Base.SortPara(DataTemp,UBound(DataTemp),"&")
  29.                 Dim Sign
  30.                 Sign = "GET&" & POPUrlEncode("/") & "&" & POPUrlEncode(Data)
  31.                 Sign = POPUrlEncode(Zasp.Encrypt.HMACSHA1(Sign,AccessKeySecret & "&","Base64"))
  32.                 SendSMS = Zasp.XMLHTTP.GetHTTP(Domain & "?Signature=" & Sign & "&" & Data,"UTF-8")
  33.         End Function
复制代码

评分

1

查看全部评分

一往情僧 发表于 2024-11-14 07:59:45 | 显示全部楼层
楼主是个好人!
 楼主| 天下第一 发表于 2024-11-14 09:23:13 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号