public YunpianClient sendsms()
        {
            //初始化clnt,使用单例方式
            var clnt      = new YunpianClient(apiKey).Init();
            var rannumber = registerhelper.GetRandomString(6);

            sendcode = rannumber;
            //发送短信API
            var param = new Dictionary <string, string>
            {
                [Const.Mobile] = TxtPhNo.Text,
                [Const.Text]   = "【朱逸渠】您的验证码是" + rannumber
            };
            var r = clnt.Sms().SingleSend(param);

            clnt.Dispose();
            return(clnt);
        }
Exemple #2
0
        public async Task SendSMS(string[] mobiles, string content)
        {
            var param = new Dictionary <string, string>
            {
                [Const.Mobile] = string.Join(",", mobiles),
                [Const.Text]   = content,
            };
            var r = yunpianClient.Sms().BatchSend(param);

            yunpianClient.Dispose();
            if (r == null)
            {
                throw new SMSApiException(500, "未知错误");
            }
            else if (r.Code != 0)
            {
                throw new SMSApiException(r.Code, r.Msg);
            }
        }
 public string SendverifyCodeYP(string phone, string verificationCode)
 {
     try
     {
         Settings.ChinaVerify = verificationCode;
         var clnt = new YunpianClient("d3a5e366f73162fe514f4883d1cd1cf3").Init();
         var param = new Dictionary<string, string>
         {
             [Const.Mobile] = phone,
             [Const.Text] = "【Cycbis】您的验证码是" + verificationCode+ "。如非本人操作,请忽略本短信",
             [Const.TplId] = "3180896",
             [Const.TplValue] = "【Cycbis】您的验证码是#code#。如非本人操作,请忽略本短信",
             [Const.Code] = verificationCode
         };
         var r = clnt.Sms().SingleSend(param);
         clnt.Dispose();
         return r.Msg;
     }
     catch (Exception e)
     {
         throw e;
     }
 }