码迷,mamicode.com
首页 > Web开发 > 详细

创蓝语音服务(语音通知验证码).net

时间:2018-09-06 14:31:37      阅读:243      评论:0      收藏:0      [点我收藏+]

标签: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

创蓝语音服务(语音通知验证码).net

标签:type   method   string   pst   ==   pass   get   https   class   

原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/9597537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!