zoukankan      html  css  js  c++  java
  • 创蓝语音服务(语音通知验证码).net

      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(返回错误的情况)

      public static string PostUrl = "http://zapi.253.com/msg/HttpBatchSendSM";
            static void Main(string[] args)
            {
                string account = "V0240532111";
                string password = "pE3e8r60wM01c5111";
                string mobile = "18516627499";
                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));
                string resultCode = "";
                HttpWebRequest myRequest = null;
                HttpWebResponse myResponse = null;
                try
                {
                    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();
    
                    myResponse = (HttpWebResponse)myRequest.GetResponse();
            
                    if (myResponse.StatusCode == HttpStatusCode.OK)
                    {
                        StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                        string result = reader.ReadToEnd();
    
                        if (result != null)
                        {
                            string[] arr = result.Split(',');
                            resultCode = arr[1];
                        }
                    }
                }catch(Exception ex)
                {
                    Console.Write(ex);
                }
                finally
                {
                    if (myRequest != null)
                    {
                        myRequest.Abort();
                    }
                    if (myResponse != null)
                    {
                        myResponse.Close();
                    }
                }
                if (resultCode.StartsWith("0"))
                {
                    Console.WriteLine("发送成功");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("发送失败" + resultCode);
                    Console.ReadKey();
                }
            }
  • 相关阅读:
    自定义控件小结进阶篇
    SQL注入语句 (很全)
    C# winform DataGridView 属性说明 [C# .NET]
    MDI窗体程序中防止子窗体被多次实例化——Singleton的C#实现
    精妙SQL语句大全
    sql语句
    注销时关闭当前窗体,返回登入界面
    C#中DataGridView的使用 [C# .NET]
    C#开发 WinForm中窗体显示和窗体传值相关知识
    HDU2553 (N皇后)
  • 原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/9597537.html
Copyright © 2011-2022 走看看