예제 #1
0
        private Result SendSms(string phone, string code, StuAcountVerifyTypeEnum type)
        {
            Result r = new Result();

            if (type == StuAcountVerifyTypeEnum.注册验证)
            {
                ShortMessageClient client = new ShortMessageClient(SmsServiceUrl());
                r = client.Send(new VerificationCodeShortMessage()
                {
                    Code = code, PhoneNumbers = phone
                });
            }
            else if (type == StuAcountVerifyTypeEnum.登录验证)
            {
                ShortMessageClient client = new ShortMessageClient(SmsServiceUrl());
                r = client.Send(new CommonShortMessage()
                {
                    PhoneNumbers = phone,
                    TemplateCode = ConfigurationManager.AppSettings["SmsTemplateCodeLogin"],
                    Parameters   = new List <ShortMessageParameter>()
                    {
                        new ShortMessageParameter
                        {
                            name  = "code",
                            value = code
                        }
                    }
                });
            }
            else if (type == StuAcountVerifyTypeEnum.身份验证)
            {
                ShortMessageClient client = new ShortMessageClient(SmsServiceUrl());
                r = client.Send(new CommonShortMessage()
                {
                    PhoneNumbers = phone,
                    TemplateCode = ConfigurationManager.AppSettings["SmsTemplateCodeVerify"],
                    Parameters   = new List <ShortMessageParameter>()
                    {
                        new ShortMessageParameter
                        {
                            name  = "code",
                            value = code
                        }
                    }
                });
            }
            return(r);
        }
예제 #2
0
        private bool SendSms(string phone, string code, AccountVerifyTypeEnum type)
        {
            string             templateCode = GetSmsConfig(type);
            ShortMessageClient client       = new ShortMessageClient(SmsServiceUrl());
            Result             r            = client.Send(new CommonShortMessage()
            {
                PhoneNumbers = phone,
                TemplateCode = templateCode,
                Parameters   = new List <ShortMessageParameter>()
                {
                    new ShortMessageParameter()
                    {
                        name  = "code",
                        value = code
                    }
                }
            });

            return(r.State);
        }