Example #1
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="tos">接收号码,多个之间用,分割</param>
        /// <param name="msg">短信内容(1-70)</param>
        /// <param name="otime">定时发送时间,为null时即时发送</param>
        /// <returns></returns>
        public static bool SendSMS(string tos, string msg, string otime)
        {
            string uid = ConfigurationManager.AppSettings["SmsUid"];
            string pwd = ConfigurationManager.AppSettings["SmsPwd"];

            try
            {
                //WebService接口实现
                Service1.Service1 service = new Service1.Service1();
                string            result  = service.SendMessages(uid, pwd, tos, msg, otime);

                //HTTP接口实现
                //string url = "http://service.winic.org/sys_port/gateway/?id=" + uid + "&pwd=" + pwd + "&to=" + tos + "&content=" + msg + "&time="+otime;
                //MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();

                //xmlhttp.open("GET", url, false, null, null);
                //xmlhttp.send("");
                //XMLDocument dom = new XMLDocument();
                //Byte[] b = (Byte[])xmlhttp.responseBody;
                //string result = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim();

                if (result.Contains("-"))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }