doVoiceSend.asp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <%
  2. url = "http://service2.winic.org:8003/Service.asmx" 'webservice 地址
  3. '==============================
  4. '通过 ADODB.Stream 流化后 用 xml 转化base64 编码 哈哈
  5. function Goodfile(filepath)
  6. Dim xmlDoc
  7. Dim xmlNode
  8. Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
  9. xmlDoc.insertBefore xmlDoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""utf-8"""), xmlDoc.childNodes(0)
  10. xmlDoc.appendChild xmlDoc.createElement("bin")
  11. Set xmlNode = xmlDoc.documentElement
  12. Dim objFile
  13. Set objFile = Server.CreateObject("ADODB.Stream")
  14. objFile.Type = 1
  15. objFile.Open
  16. objFile.LoadFromFile filepath
  17. xmlNode.dataType = "bin.base64"
  18. xmlNode.nodeTypedValue = objFile.Read(-1)
  19. objFile.Close
  20. Set objFile = Nothing
  21. Response.ContentType = "text/html"
  22. Goodfile=xmlNode.Text
  23. ' Response.ContentType = "text/xml"
  24. 'xmlDoc.Save Response
  25. Set xmlDoc = Nothing
  26. end function
  27. '=======================================
  28. '==============================发送短信函数
  29. function SendVoice(uid,pwd,vto,vtxt,vmode,vfbtye,svrno,str_time,end_time)
  30. SoapRequest="<?xml version="&CHR(34)&"1.0"&CHR(34)&" encoding="&CHR(34)&"utf-8"&CHR(34)&"?>"& _
  31. "<soap:Envelope xmlns:xsi="&CHR(34)&"http://www.w3.org/2001/XMLSchema-instance"&CHR(34)&" "& _
  32. "xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" "& _
  33. "xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&">"& _
  34. "<soap:Body>"& _
  35. "<SendVoice xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&">"& _
  36. "<uid>"&uid&"</uid>"& _
  37. "<pwd>"&pwd&"</pwd>"& _
  38. "<vto>"&vto&"</vto>"& _
  39. "<vtxt>"&vtxt&"</vtxt>"& _
  40. "<mode>"&vmode&"</mode>"& _
  41. "<FileBytes>"&vfbtye&"</FileBytes>"& _
  42. "<svrno>"&svrno&"</svrno>"& _
  43. "<str_time>"&str_time&"</str_time>"& _
  44. "<end_time>"&end_time&"</end_time>"& _
  45. "</SendVoice>"& _
  46. "</soap:Body>"& _
  47. "</soap:Envelope>"
  48. Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
  49. xmlhttp.Open "POST",url,false
  50. xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
  51. xmlhttp.setRequestHeader "HOST","service2.winic.org"
  52. xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
  53. xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/SendVoice" '一定要与WEBSERVICE的命名空间相同,否则服务会拒绝
  54. xmlhttp.Send(SoapRequest)
  55. ''样就利用XMLHTTP成功发送了与SOAP示例所符的SOAP请求.'检测一下是否返回200=成功:
  56. If xmlhttp.Status = 200 Then
  57. Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
  58. xmlDOC.load(xmlhttp.responseXML)
  59. SendVoice=xmlDOC.documentElement.selectNodes("//SendVoiceResult")(0).text '显示节点为GetUserInfoResult的数据(返回字符串)
  60. Set xmlDOC = nothing
  61. Else
  62. SendVoice=xmlhttp.Status&"&nbsp;"
  63. SendVoice=xmlhttp.StatusText
  64. End if
  65. Set xmlhttp = Nothing
  66. end function
  67. '================================取数组中的一个
  68. function split_str(str,sint)
  69. on error resume next
  70. dim tempstr
  71. tempstr=split(str,"/") '/号分割
  72. split_str=tempstr(sint)
  73. end function
  74. '==============================
  75. dim vfbtye
  76. uid="your_id" '你申请的用户名
  77. pwd="your_pwd" '你申请的密码
  78. vto=request("telNo") '电话号码
  79. vtxt=request("tre_Note_Content") '语音内容
  80. vmode=request("rbt_Sound_mode") '传送方式
  81. svrno=request("txt_Sound_phone") '服务号码 最多五个 用逗号(",")隔分
  82. str_time=""
  83. end_time=""
  84. txtPhone=trim(request.Form("telNo")) '群发号码用逗号(",")分隔
  85. txtPhone=replace(txtPhone,chr(10),",")
  86. txtPhone=replace(txtPhone,chr(13),"")
  87. txtPhone=replace(txtPhone," ","")
  88. txtPhone=replace(txtPhone,",",",")
  89. IF vmode = "3" THEN
  90. '注意: 取绝对路径哦。如果在服务器上要先文件上传到服务器 再取文件绝对路径 如"d:xx.doc"
  91. vfbtye=Goodfile(request.Form("file_Sound"))
  92. END IF
  93. msg =SendVoice(uid,pwd,txtPhone,vtxt,vmode,vfbtye,svrno,str_time,end_time )
  94. if len(msg)>5 then
  95. errmsg="恭喜!发送成功:编号是:"&msg
  96. else
  97. errmsg="发送失败:错误码是:"&msg
  98. end if
  99. response.Write "<script language=javascript>alert('"&errmsg&"');location.href ='voiceSend.asp';</script>"
  100. %>