asp DEMO

功能说明:该接口要求提前在云片后台添加模板,提交短信时,系统会自动匹配审核通过的模板,匹配成功任意一个模板即可发送。系统已提供的默认模板添加签名后可以直接使用。

  1. <%
  2. '安装IIS并重启后可用
  3. @LANGUAGE="VBSCRIPT" CODEPAGE="65001"
  4. %>
  5. <%
  6. response.contenttype = "text/html;charset=utf-8"
  7. '提交方法
  8. method = "POST"
  9. '您要发送的手机号
  10. mobile = Server.URLEncode("xxxxxxxxxxx")
  11. '修改为您的apikey(https://www.yunpian.com)登录官网后获取
  12. apikey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  13. '发送内容
  14. text ="【云片网】您的验证码是1234"
  15. '使用模板号
  16. tpl_id = 1
  17. '使用模板内容
  18. tpl_value = Server.URLEncode("#code#=1234&#company#=云片网")
  19. '查询账户信息https地址
  20. url_get_user = "https://sms.yunpian.com/v2/user/get.json"
  21. '智能匹配模板发送https地址
  22. url_send_sms = "https://sms.yunpian.com/v2/sms/single_send.json"
  23. '指定模板发送接口https地址
  24. url_tpl_sms = "https://sms.yunpian.com/v2/sms/tpl_single_send.json"
  25. '发送语音验证码接口https地址
  26. url_send_voice = "https://voice.yunpian.com/v2/voice/send.json"
  27. data_get_user = "apikey=" & apikey
  28. data_send_sms = "apikey=" & apikey & "&mobile=" & mobile & "&text=" & text
  29. data_tpl_sms = "apikey=" & apikey & "&mobile=" & mobile & "&tpl_id=" & tpl_id &_
  30. "&tpl_value=" & tpl_value
  31. data_send_voice = "apikey=" & apikey & "&mobile=" & mobile & "&code=" & "1234"
  32. response.write GetBody(url_get_user,data_get_user)
  33. response.write GetBody(url_send_sms,data_send_sms)
  34. response.write GetBody(url_tpl_sms,data_tpl_sms)
  35. response.write GetBody(url_send_voice,data_send_voice)
  36. Function GetBody(url,data)
  37. Set https = Server.CreateObject("MSXML2.ServerXMLHTTP")
  38. With https
  39. .Open method, url, False
  40. .setRequestHeader "Content-Type","application/x-www-form-urlencoded"
  41. .Send data
  42. GetBody= .ResponseBody
  43. End With
  44. GetBody = bytetostr(https.ResponseBody,"utf-8")
  45. Set https = Nothing
  46. End Function
  47. function bytetostr(vin,cset)
  48. dim bs,sr
  49. set bs = server.createObject("adodb.stream")
  50. bs.type = 2
  51. bs.open
  52. bs.writetext vin
  53. bs.position = 0
  54. bs.charset = cset
  55. bs.position = 2
  56. sr = bs.readtext
  57. bs.close
  58. set bs = nothing
  59. bytetostr = sr
  60. end function
  61. %>