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();
                }
            }
  • 相关阅读:
    cocos2d-x3.0 PageView
    mysql 安装配置及经常使用操作
    Android自己定义组件系列【6】——进阶实践(3)
    hdu 4300 Clairewd’s message(具体解释,扩展KMP)
    VS"后生成事件" 菜单的使用
    CUDA 实现JPEG图像解码为RGB数据
    Hibernate操作Blob数据
    android清除缓存为什么总是存在12k?
    JSP入门
    Linux字符设备驱动结构(一)--cdev结构体、设备号相关知识机械【转】
  • 原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/9597537.html
Copyright © 2011-2022 走看看