其它示例.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. 提示:HTTP调用URL接口时, 参数值必须URL编码后再调用
  2. --x_eid企业代码,个人账号值为0
  3. --x_gate_id值为300.代表组合通道
  4. --x_target_no可以多个号码最多100个每次。之间用[,]分开。例如:15910011001,1591061000,15912341234
  5. --x_memo短信内容70字
  6. --查询余额
  7. http://gateway.woxp.cn:6630/gb2312/web_api/?x_eid=企业ID&x_uid=账号&x_pwd_md5=登陆密码MD5值&x_ac=30&x_gate_id=300
  8. 1. --ASP 调用例子-------------------------------------------------------------------------------------------
  9. <%
  10. '常用函数
  11. '输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
  12. function getHTTPPage(url)
  13. dim Http
  14. set Http=server.createobject("MSXML2.XMLHTTP")
  15. Http.open "GET",url,false
  16. Http.send()
  17. if Http.readystate<>4 then
  18. exit function
  19. end if
  20. getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
  21. set http=nothing
  22. if err.number<>0 then err.Clear
  23. end function
  24. Function BytesToBstr(body,Cset)
  25. dim objstream
  26. set objstream = Server.CreateObject("adodb.stream")
  27. objstream.Type = 1
  28. objstream.Mode =3
  29. objstream.Open
  30. objstream.Write body
  31. objstream.Position = 0
  32. objstream.Type = 2
  33. objstream.Charset = Cset
  34. BytesToBstr = objstream.ReadText
  35. objstream.Close
  36. set objstream = nothing
  37. End Function
  38. '自已组合一下提交的URL加入自己的账号和密码MD5
  39. sms_url="http://gateway.woxp.cn:6630/gb2312/web_api/?x_eid=&x_uid=&x_pwd_md5=&x_ac=10&x_gate_id=101&x_target_no=&x_memo="
  40. response.write getHTTPPage(sms_url)
  41. %>
  42. 2.--C# 调用---------------------------------------------------------------------------------------------
  43. //需要用到的命名空间
  44. using System.Net;
  45. using System.IO;
  46. using System.Text;
  47. //调用时只需要把拼成的URL传给该函数即可。判断返回值即可
  48. public string GetHtmlFromUrl(string url)
  49. {
  50. string strRet = null;
  51. if(url==null || url.Trim().ToString()=="")
  52. {
  53. return strRet;
  54. }
  55. string targeturl = url.Trim().ToString();
  56. try
  57. {
  58. HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
  59. hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
  60. hr.Method = "GET";
  61. hr.Timeout = 30 * 60 * 1000;
  62. WebResponse hs = hr.GetResponse();
  63. Stream sr = hs.GetResponseStream();
  64. StreamReader ser = new StreamReader(sr, Encoding.Default);
  65. strRet = ser.ReadToEnd();
  66. }
  67. catch (Exception ex)
  68. {
  69. strRet = null;
  70. }
  71. return strRet;
  72. }
  73. 3.---JAVA调用----------------------------------------------------------------------------------------------
  74. import java.io.BufferedReader;
  75. import java.io.IOException;
  76. import java.io.InputStreamReader;
  77. import java.io.UnsupportedEncodingException;
  78. import java.net.HttpURLConnection;
  79. import java.net.MalformedURLException;
  80. import java.net.URL;
  81. import java.net.URLEncoder;
  82. /**
  83. * 发送短信基础类
  84. * @author administration
  85. *
  86. */
  87. public class SmsBase {
  88. private Integer x_eid=0;
  89. private String x_uid="username";
  90. private String x_pwd_md5="md5pass";
  91. private Integer x_gate_id=300;
  92. public String SendSms(String mobile,String content) throws UnsupportedEncodingException{
  93. Integer x_ac=10;//发送信息
  94. HttpURLConnection httpconn = null;
  95. String result="-20";
  96. String memo = content.length()<70?content.trim():content.trim().substring(0, 70);
  97. StringBuilder sb = new StringBuilder();
  98. sb.append("http://gateway.woxp.cn:6630/utf8/web_api/?x_eid=");
  99. sb.append(x_eid);
  100. sb.append("&x_uid=").append(x_uid);
  101. sb.append("&x_pwd_md5=").append(x_pwd_md5);
  102. sb.append("&x_ac=").append(x_ac);
  103. sb.append("&x_gate_id=").append(x_gate_id);
  104. sb.append("&x_target_no=").append(mobile);
  105. sb.append("&x_memo=").append(URLEncoder.encode(memo, "utf-8"));
  106. try {
  107. URL url = new URL(sb.toString());
  108. httpconn = (HttpURLConnection) url.openConnection();
  109. BufferedReader rd = new BufferedReader(new InputStreamReader(httpconn.getInputStream()));
  110. result = rd.readLine();
  111. rd.close();
  112. } catch (MalformedURLException e) {
  113. // TODO Auto-generated catch block
  114. e.printStackTrace();
  115. } catch (IOException e) {
  116. // TODO Auto-generated catch block
  117. e.printStackTrace();
  118. } finally{
  119. if(httpconn!=null){
  120. httpconn.disconnect();
  121. httpconn=null;
  122. }
  123. }
  124. return result;
  125. }
  126. }
  127. ------4 PHP----------------------------------------------------------------------------------
  128. $url='http://gateway.woxp.cn:6630/gb2312/web_api/?x_eid=&x_uid=&x_pwd_md5=&x_ac=10&x_target_no=&x_memo=test&x_gate_id=300';
  129. echo Get($url);
  130. function Get($url)
  131. {
  132. if(function_exists('file_get_contents'))
  133. {
  134. $file_contents = file_get_contents($url);
  135. }
  136. else
  137. {
  138. $ch = curl_init();
  139. $timeout = 5;
  140. curl_setopt ($ch, CURLOPT_URL, $url);
  141. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  142. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  143. $file_contents = curl_exec($ch);
  144. curl_close($ch);
  145. }
  146. return $file_contents;
  147. }
  148. 5.VB.NET-------------------------------------------------------------------------------------
  149. '调用发送短信,NoList接收号码.多个之间用,分开,Memo内容70字
  150. Public Function SendSMS(ByVal NoList As String, ByVal Memo As String) As String
  151. Dim Url As String = "http://gateway.woxp.cn:6630/gb2312/web_api/?x_eid=企业ID&x_uid=会员帐号&x_pwd_md5=MD5登录密码&x_ac=10&x_gate_id=300&x_memo=" & Memo & "&x_target_no=" & NoList
  152. Dim webClient As New Net.WebClient()
  153. Try
  154. 'Dim responseData As Byte() =
  155. Dim srcString As String = webClient.DownloadString(Url)
  156. Return srcString
  157. Catch
  158. Return "-444"
  159. End Try
  160. End Function