zoukankan      html  css  js  c++  java
  • 短信发送

    中国短信网的发送接口:

        /// <summary>
        /// 发送短信并返回结果
        /// </summary>
        /// <param name="hm">号码</param>
        /// <param name="nr">内容</param>
        /// <returns></returns>
        public static String fs(string hm, string nr)
        {
            StringBuilder sbTemp = new StringBuilder();

            sbTemp.Append("uid=*****&pwd=*****&mobile=" + hm + "&content=" + nr);
            byte[] bTemp = System.Text.Encoding.GetEncoding("GBK").GetBytes(sbTemp.ToString());
            String postReturn = Define.doPostRequest("http://http.c123.com/tx/", bTemp);
            return postReturn;
        }
        //POST方式发送得结果
        public static String doPostRequest(string url, byte[] bData)
        {
            System.Net.HttpWebRequest hwRequest;
            System.Net.HttpWebResponse hwResponse;

            string strResult = string.Empty;
            try
            {
                hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
                hwRequest.Timeout = 5000;
                hwRequest.Method = "POST";
                hwRequest.ContentType = "application/x-www-form-urlencoded";
                hwRequest.ContentLength = bData.Length;

                System.IO.Stream smWrite = hwRequest.GetRequestStream();
                smWrite.Write(bData, 0, bData.Length);
                smWrite.Close();
            }
            catch (System.Exception err)
            {
                WriteErrLog(err.ToString());
                return strResult;
            }

            //get response
            try
            {
                hwResponse = (HttpWebResponse)hwRequest.GetResponse();
                StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.ASCII);
                strResult = srReader.ReadToEnd();
                srReader.Close();
                hwResponse.Close();
            }
            catch (System.Exception err)
            {
                WriteErrLog(err.ToString());
            }

            return strResult;
        }
        public static void WriteErrLog(string strErr)
        {
            Console.WriteLine(strErr);
            System.Diagnostics.Trace.WriteLine(strErr);
        }

     这个网站只能接收到别人回复的短信,不能设置接收的号码,跟我的需求不同,就没继续使用下去,过几天我用其他的接口实现了短信查询功能后,再贴出来…

  • 相关阅读:
    sqlISNULL函数(转载)
    sql数据导入导出(转载)
    sqlbcp
    SQL连接方式(左连接、右连接、全连接)转载
    陶哲轩实分析 习题 7.2.6 (嵌套级数)
    陶哲轩实分析 命题7.2.5 证明
    陶哲轩实分析 定义 7.2.1(形式无限级数) 的一点注记
    陶哲轩实分析 推论 7.3.2 (比较判别法) 证明
    陶哲轩实分析 习题 7.2.6 (嵌套级数)
    陶哲轩实分析 命题 7.2.14 (极限算律) 证明
  • 原文地址:https://www.cnblogs.com/_zjl/p/2021873.html
Copyright © 2011-2022 走看看