C# HTTP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Net;
using System.IO;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
try
{
Encoding myEncoding = Encoding.GetEncoding("utf-8");
string param = HttpUtility.UrlEncode("account", myEncoding) +
"=" + HttpUtility.UrlEncode("jz004", myEncoding) +
"&" + HttpUtility.UrlEncode("password", myEncoding) +
"=" + HttpUtility.UrlEncode("xxxxx", myEncoding) +
"&" + HttpUtility.UrlEncode("destmobile", myEncoding) +
"=" + HttpUtility.UrlEncode("18717830363", myEncoding) +
"&" + HttpUtility.UrlEncode("msgText", myEncoding) +
"=" + HttpUtility.UrlEncode("c#的问候c#的问候【建周科技】", myEncoding) +
"&" + HttpUtility.UrlEncode("sendDateTime", myEncoding) +
"=" + HttpUtility.UrlEncode("", myEncoding);
byte[] postBytes = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)
HttpWebRequest.Create("http://www.jianzhou.sh.cn/JianzhouSMSWSServer/http/sendBatchMessage");
req.Method = "POST";
req.ContentType =
"application/x-www-form-urlencoded;charset=utf-8";
req.ContentLength = postBytes.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(postBytes, 0, postBytes.Length);
}
//using (WebResponse wr = req.GetResponse())
//{
//在这里对接收到的页面内容进行处理
//}
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}