Exemplo n.º 1
0
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static bool SendSms(string phone, string code)
        {
            try
            {
                SmsSingleSenderResult singleResult;
                SmsSingleSender       singleSender = new SmsSingleSender(SmsConfig.APPID, SmsConfig.APPKEY);


                List <string> templParams = new List <string>();
                templParams.Add(code);
                // 指定模板单发
                singleResult = singleSender.SendWithParam("86", phone, SmsConfig.TMPLID, templParams, "", "", "");

                if (singleResult.result == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送预警短信
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static bool SendWarn(string phone, string deviceName)
        {
            try
            {
                SmsSingleSenderResult singleResult;
                SmsSingleSender       singleSender = new SmsSingleSender(SmsConfig.APPID, SmsConfig.APPKEY);

                List <string> templParams = new List <string>();
                templParams.Add(deviceName);
                // 指定模板单发
                singleResult = singleSender.SendWithParam("86", phone, SmsConfig.WARNID, templParams, "", "", "");

                if (singleResult.result == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }