标签:type method string pst == pass get https class
public static string PostUrl = "http://zapi.253.com/msg/HttpBatchSendSM"; static void Main(string[] args) { string account = ""; string password = ""; string mobile = "1"; string content = "您的登陆验证码是1234"; string postStrTpl = "account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product=&extno="; UTF8Encoding encoding = new UTF8Encoding(); byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content)); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = postData.Length; Stream newStream = myRequest.GetRequestStream(); // Send the data. newStream.Write(postData, 0, postData.Length); newStream.Flush(); newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); if (myResponse.StatusCode == HttpStatusCode.OK) { StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); myResponse.Close(); myRequest.Abort(); Console.WriteLine("发送成功"); Console.ReadKey(); } else { myRequest.Abort(); myResponse.Close(); Console.WriteLine("发送失败"); Console.ReadKey(); } }
创蓝语音服务.net
标签:type method string pst == pass get https class
原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/9597537.html