wzp
2021-07-30 afda40ef498cca59e58b2b6869deae90f3c13de5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
 
namespace ThreadTestSMGW
{
    public class TornadoSMSHandler
    {
 
        //URL读取配置文件
        public static string SITEURL = System.Configuration.ConfigurationManager.AppSettings["URL"];
 
        public string SendSMS(string un, string pw, string da, string hex)
        {
            string time = System.DateTime.Now.ToString();
 
            string other = "&dc=15&rd=1";
 
 
            string requestUrl = SITEURL + "?un=" + un + "&pw=" + pw + "&da=" + da + "&sm=" + hex + other; //请求地址
            StreamReader reader; //实现一个 TextReader(表示可读取连续字符系列的读取器。),使其以一种特定的编码从字节流中读取字符。
            Uri requestUri = new Uri(requestUrl); //Uri 类,提供统一资源标识符 (URI) 的对象表示形式和对 URI 各部分的轻松访问。
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
            //提供 WebRequest 类的 HTTP 特定的实现。
            request.Method = "Get";
            request.ContentType = "application/x-www-form-urlencoded";
            request.KeepAlive = true;
            request.Timeout = 1000000;
 
            WebResponse response = (HttpWebResponse)request.GetResponse();
            reader = new StreamReader(response.GetResponseStream());
 
            StringBuilder builder = new StringBuilder();
            char[] buffer = new char[0x400];
            int charCount = 0;
            while ((charCount = reader.Read(buffer, 0, buffer.Length)) > 0)
            {
                builder.Append(buffer, 0, charCount);
            }
            reader.Close();
            return builder.ToString();
        }
    }
}