public static bool SendCode(string phone, out string msg) { msg = "发送成功"; Random r = new Random(DateTime.Now.Millisecond); StringBuilder code = new StringBuilder(); for (int i = 0; i < 5; i++) { code.Append(CodesString[r.Next(CodesString.Length)]); } string[] arrCont = { code.ToString(), _ExpriedMin.ToString() }; if (authobj.AddSmsCodeToDB(phone, arrCont[0], _ExpriedMin)) { Dictionary <string, object> retData = api.SendTemplateSMS(phone, _SmsTemplateID, arrCont); if (retData["statusCode"].ToString() == "000000") { return(true); } else { msg = retData["statusMsg"].ToString(); return(false); } } else { msg = "验证码写入数据库失败"; return(false); } }
/// <summary> /// 模板短信 /// </summary> /// <param name="to">短信接收端手机号码集合,用英文逗号分开,每批发送的手机号数量不得超过100个</param> /// <param name="templateId">模板Id</param> /// <param name="data">可选字段 内容数据,用于替换模板中{序号}</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> /// <exception cref="Exception"></exception> /// <returns></returns> public static string SendTemplateSMS(string to, string templateId, string[] data) { string ret = null; try { if (_isInit) { Dictionary <string, object> retData = _api.SendTemplateSMS(to, templateId, data); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { } return(ret); }
public bool sendSuccessBookingMsg(string mobile, string doctorName) { string bookingsuccess = ConfigurationManager.AppSettings["bookingsuccess"].ToString(); string[] content = new string[] { doctorName }; try { CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(ServerIP, ServerPort); api.setAccount(AccountSid, AccountToken); api.setAppId(AppId); if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(mobile, bookingsuccess, content); ret = getDictionaryData(retData); return(true); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return(false); }
public void SendSMS(string templateId,string mobile,string[] content) { var ret = string.Empty; var api = new CCPRestSDK.CCPRestSDK(); var isInit = api.init(this.SMS_SiteUrl, this.SMS_SitePort); api.setAppId(this.SMS_AppID); api.setAccount(this.SMS_Account, this.SMS_AccountPassword); try { if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(mobile, templateId, content); ret = GetDictionaryData(retData); } else { LogHelper.Info("连接短信服务器失败!"); } } catch (Exception error) { LogHelper.AppError(error.Message); } }
private string sendYzm(string phone, string yyid, string[] arr) { string result = "0"; string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("aaf98f894e8a784b014e8b9aacc30280", "3c12c5c2d099444cbf42bed59067989d"); api.setAppId("8a48b5514e8a7522014e9098fef207d1"); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(phone, yyid, arr); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } if (ret.IndexOf("000000") > -1) { result = "1"; } return(result); }
public bool sendSuccessBookingMsg(string mobile,string doctorName) { string bookingsuccess = ConfigurationManager.AppSettings["bookingsuccess"].ToString(); string[] content = new string[] { doctorName }; try { CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(ServerIP, ServerPort); api.setAccount(AccountSid, AccountToken); api.setAppId(AppId); if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(mobile, bookingsuccess, content); ret = getDictionaryData(retData); return true; } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return false; }
protected void Page_Load(object sender, EventArgs e) { string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount(主帐号, 主帐号令牌); api.setAppId(应用ID); try { if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(短信接收号码, 短信模板id, 内容数据); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Response.Write(ret); } }
public static string SendMessage(string phoneNum) { CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount(RLY_AccountSID, RLY_AuthToken); api.setAppId(RLY_AomulaiteAppId); if (!isInit) { throw new Exception("短信初始化失败"); } Random ran = new Random(); var verifyCode = ran.Next(100000, 999999); Dictionary <string, object> retData = api.SendTemplateSMS(phoneNum, "115658", new string[] { verifyCode.ToString(), "2" }); if (retData["statusMsg"].ToString() == "成功") { return(verifyCode.ToString()); } else { throw new Exception(retData["statusMsg"].ToString()); } //string ret = getDictionaryData(retData); }
public static string SendSMS(string Tel, string TempID, string[] body) { CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514eab0c78014eaea1993b0297", "850b081bb8674e9a99caa8875ee29063"); api.setAppId("8aaf070856ea05c20156ea1e81b8004a"); string ret = string.Empty; try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(Tel, TempID, body); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return(ret); }
/// <summary> /// 发送短信 /// </summary> /// <param name="backstr">反馈消息</param> /// <param name="to">短信接收端手机号码集合,用英文逗号分开,每批发送的手机号数量不得超过100个</param> /// <param name="templateId">模板Id</param> /// <param name="data">可选字段 内容数据,用于替换模板中{序号}</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> /// <exception cref="Exception"></exception> /// <returns></returns> static bool Send(ref string backstr, string to, string templateId, string[] data) { bool b = false; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b551544cd73f01547f619c4e3068", "1c5ac6e9ea504ba6a1924e2df83f2551"); api.setAppId("aaf98f89544cd9d901547f6cc2a22ecd"); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(to, templateId, data); backstr = getDictionaryData(retData); b = true; } else { backstr = "初始化失败"; } } catch (Exception exc) { backstr = exc.Message; } return(b); }
/// <summary> /// 发送短信(重试3次) /// </summary> /// <param name="phoneNos">电话号码集合,逗号分隔</param> /// <param name="templateId">模版Id</param> /// <param name="content">短信内容</param> /// <returns>是否发送成功</returns> public bool Send(string phoneNos, int templateId = 0, params string[] content) { return(RetryHelper.Retry(() => { Dictionary <string, object> result = _api.SendTemplateSMS(phoneNos, templateId.ToString(), content); return (string)result["statusCode"] == "000000"; }, 4)); }
/// <summary> /// 发送短信验证码 /// </summary> public JsonResult SentSMSCode(string phoneNumber, string username, string flagstatus) { string ret = null; string sendtime = ""; string expiretime = ""; DataTable dt = BusinessDataService.LubrRegisterService.GetUSerSMSCodeExpireTime(phoneNumber); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { sendtime = dt.Rows[i]["SENDTIME"].ToString(); expiretime = dt.Rows[i]["EXPIRETIME"].ToString(); TimeSpan ts = DateTime.Now - DateTime.Parse(sendtime); if (ts.Minutes < expiretime.ToInt()) { ret = "{\"statusCode\":\"1\"}"; return(Json(ret)); } } } CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a216da86b652116016b77bfba220ef5", "cf633b3910a04b61a22af6734b5f91c3"); //测试,此处api以及appid均为cs测试账户 充值后会有新的,填入即可 //api.setAccount("8a216da86b652116016b77bfba220ef", "cf633b3910a04b61a22af6734b5f91c"); api.setAppId("8a216da86b652116016b77bfba8a0efc"); //测试 //api.setAppId("8a216da86b652116016b77bfba8a0ef"); try { if (isInit) { var SMSCode = BusinessDataService.LubrRegisterService.NewUserSentSMSCode(phoneNumber, username, flagstatus); //cs测试把此注释 //Dictionary<string, object> retData = api.SendTemplateSMS("15935141467", "1", new string[] { SMSCode, "1" }); //三个参数分别为需要发送的手机号码、模板类型(此处为测试模板1,可以修改)、模板中需要替换的参数 Dictionary <string, object> retData = api.SendTemplateSMS(phoneNumber, "1", new string[] { SMSCode, "1" }); //cs测试把此注释,不发短信 ret = JsonConvert.SerializeObject(retData); //ret = "{\"statusCode\":\"000000\"}"; return(Json(ret)); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } return(Json(ret)); }
public static MessageResult SendTempleteSMS(string phone, string templeteId, string[] arsg) { phone.AssertNotNull("phone"); templeteId.AssertNotNull("templeteId"); arsg.AssertNotNull("arsg"); if (false == new Regex(@"1\d{10}").IsMatch(phone)) { return(MessageResult.FailedResult("-1", "手机号不正确")); } var apiClient = new CCPRestSDK.CCPRestSDK(); bool isInit = apiClient.init("app.cloopen.com", "8883"); apiClient.setAccount(SmsYTX_AccountSId, SmsYTX_AccountToken); apiClient.setAppId(SmsYTX_AppId); try { if (isInit) { Dictionary <string, object> retData = apiClient.SendTemplateSMS(phone, templeteId, arsg); if (null != retData && retData.ContainsKey("statusCode") && retData["statusCode"].ToString() == "000000") { return(MessageResult.SuccessResult()); } else { if (null != retData && retData.ContainsKey("statusCode")) { return(MessageResult.FailedResult(retData["statusCode"].ToString(), retData["statusMsg"].ToString())); } else { return(MessageResult.FailedResult("-9", "发送失败")); } } } else { return(MessageResult.FailedResult("-1", "初始化失败")); } } catch (Exception exc) { return(MessageResult.FailedResult("-" + exc.GetType().Name, exc.Message)); } finally { //Response.Write(ret); } }
/// <summary> /// 发送验证码-带业务名称 /// </summary> /// <param name="companyId">商户ID</param> /// <param name="telephone">手机号</param> /// <param name="verificationCode">验证码</param> /// <param name="business">业务介绍</param> public SendSMSlogEntity SendSMSVerify(string tenantId, string telephone, string verificationCode, string business) { //http://www.yuntongxun.com/ CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount(AccountSid, AccountToken); api.setAppId(AppId); var model = new SendSMSlogEntity(); if (!isInit) { model.State = false; return(model); } Dictionary <string, object> retData = null; try { string[] phoneList = telephone.Split(new char[] { ',' }); foreach (string phone in phoneList) { if (phone == "" || phone.Length != 11) { continue; } retData = api.SendTemplateSMS(telephone, "318597", new string[] { business, verificationCode }); model.Response = getDictionaryData(retData); model.Id = Guid.NewGuid().ToString(); model.TenantId = tenantId; model.Phone = telephone; model.VerificationCode = verificationCode; model.CreateTime = DateTime.Now; model.State = true; model.StateCode = "200"; model.Remarks = "您" + business + ",验证码是{2}。提示:请勿泄露验证码给他人"; } } catch (Exception ex) { model.State = false; model.Remarks = ex.Message; } return(model); }
/// <summary> /// 发送短信验证码 /// </summary> /// <param name="phoneNumber"></param> /// <param name="randomNum"></param> /// <returns></returns> public static Dictionary <string, object> SendSMS(string phoneNumber, string randomNum) { Dictionary <string, object> retData = new Dictionary <string, object>(); string[] data = { randomNum, SMS.TIME_OUT }; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); bool isInit = api.init(SMS.ADDRESS, SMS.PORT); api.setAccount(SMS.ACCOUNT_SID, SMS.ACCOUNT_TOKEN); api.setAppId(SMS.APP_ID); if (isInit) { retData = api.SendTemplateSMS(phoneNumber, SMS.TEMPLATE_ID, data); } return(retData); }
//statusCode=000000;statusMsg=成功;data={TemplateSMS={dateCreated=20160729163137;smsMessageSid=cdd8c497980a4a3d9fc8e9ce727f86e5;};}; public ExpSMSResponse SendSMS(string to, string templateId, string[] data) { ExpSMSResponse expRes = new ExpSMSResponse(); if (IsSMS == 1) { string ret = ""; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(RestURL, RestPort); api.setAccount(AcountSID, AuthToken); api.setAppId(AppID); try { if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(to, templateId, data); // ret = getDictionaryData(retData); expRes = GetMsgFromDicData(retData); } else { ret = "初始化失败"; expRes = new ExpSMSResponse("0", "初始化失败"); } return expRes; } catch (Exception exc) { ret = exc.Message; expRes = new ExpSMSResponse("-1", exc.Message); return expRes; } } else { expRes.statusCode = "-1"; expRes.statusMsg = "未开启短信发送!"; return expRes; } }
public IActionResult Send(string cpacha, string phone) { string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8aaf07086ab0c082016ad31e9cdc16f2", "4bc6f13fd81343e38bf6b758817de76d"); api.setAppId("8aaf07086ab0c082016ad31e9d2a16f8"); try { if (isInit) { string[] strings = { cpacha, "2" }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "1", strings); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Console.WriteLine(ret);//Response.Write(ret); } _logger.LogInformation("短信发送成功"); CustomStatusCode code = new CustomStatusCode { Status = "200", Message = "短信发送成功" }; return(StatusCode(200, code)); }
/// <summary> /// 发送短信 /// </summary> /// <param name="phone"></param> /// <param name="messageCode"></param> /// <param name="message"></param> public void SendMessage(string phone, string messageCode, string[] message) { CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); bool isInit = api.init(ConfigHelper.GetConfigString("Madd"), ConfigHelper.GetConfigString("Mport")); api.setAccount(ConfigHelper.GetConfigString("Maccount"), ConfigHelper.GetConfigString("Mtoken")); api.setAppId(ConfigHelper.GetConfigString("Mappid")); if (isInit) { //string[] strmessage = new string[] { // Validatecode, // ConfigHelper.GetConfigString("Mpasstime") //}; Dictionary <string, object> retData = api.SendTemplateSMS(phone, messageCode, message); string ret = getDictionaryData(retData); } else { //ret = "初始化失败"; } }
public static bool SendSMS(string phone, string templateID, string[] data) { var api = new CCPRestSDK.CCPRestSDK(); bool isInit = api.init(ConfigurationManager.AppSettings["sms_restaddress"].ToString(), ConfigurationManager.AppSettings["sms_restpoint"].ToString()); api.setAccount(ConfigurationManager.AppSettings["sms_account"].ToString(), ConfigurationManager.AppSettings["sms_pwd"].ToString()); api.setAppId(ConfigurationManager.AppSettings["sms_appid"].ToString()); if (!isInit) { throw new BusinessException("短信接口初始化失败!"); } Logger.WriteLog(ConfigurationManager.AppSettings["sms_restaddress"].ToString()); var retData = api.SendTemplateSMS(phone, templateID, data); if (retData["statusCode"].ToString() == "000000") { return(true); } throw new BusinessException(retData["statusMsg"].ToString()); // return retData["statusCode"].ToString() == "000000"; }
/// <summary> /// /// </summary> /// <returns></returns> string DoPay() { try { decimal tax = decimal.Parse(this.TaxBox.Text.Trim()); decimal charges = decimal.Parse(this.ChargesBox.Text.Trim()); ItemInfo.Paytime = DateTime.Now; ItemInfo.Tax = tax; ItemInfo.Charges = charges; bool result = viviapi.BLL.Finance.Withdraw.Instance.Complete(ItemInfo); if (result == true) { if (!string.IsNullOrEmpty(UserInfo.Tel)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5515018a0f4015045e342b14990", "07c2d4f927a1443fb4ffffe158ee39b8"); api.setAppId("8a216da8567745c001568c78ae030d62"); #endregion string[] data = { UserInfo.full_name, ItemInfo.Amount.ToString("f2") }; Dictionary <string, object> retData = api.SendTemplateSMS(UserInfo.Tel, "108968", data); //短信发送失败 if (retData["statusCode"].ToString() != "000000") { return("操作成功,通知短信发送失败.statusCode:" + retData["statusCode"] + ",statusMsg:" + retData["statusMsg"]); } } return("操作成功"); } else { return("操作失败"); } //else if (result == 0) //{ // #region send sms // string smscontext = viviapi.BLL.SysConfig.sms_temp_tocash; // if (!string.IsNullOrEmpty(smscontext) && !string.IsNullOrEmpty(UserInfo.Tel)) // { // smscontext = smscontext.Replace("{@username}", UserInfo.UserName); // smscontext = smscontext.Replace("{@settledmoney}", ItemInfo.amount.ToString("f2")); // viviapi.BLL.Tools.SMS.Send(UserInfo.Tel, smscontext, ""); // } // #endregion // if (ItemInfo.suppid > 0) // { // //ETAPI.Common.Withdraw.InitDistribution(ItemInfo); // } // return ""; //} //return "err"; } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(ex.Message); } }
protected void btnbacksubmit_Click(object sender, EventArgs e) { string errmsg = CheckValiDateNo(this.txtcheckCode.Value); if (!string.IsNullOrEmpty(errmsg)) { this.showmsg.Attributes["class"] = "showno"; this.showmsg.Visible = true; this.showmsg.InnerText = errmsg; return; } string findmode = ddlfindmode.SelectedValue; #region 手机找回 if (findmode == "1") { if (this.txtphone.Value != userInfo.Tel) { this.showmsg.Attributes["class"] = "showno"; this.showmsg.Visible = true; this.showmsg.InnerText = "您输入的手机号码错误"; return; } else { string phone = this.txtphone.Value; string validcode = new Random().Next(100000, 999999).ToString(); #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5515018a0f4015045e342b14990", "07c2d4f927a1443fb4ffffe158ee39b8"); api.setAppId("8a216da8567745c001568c78ae030d62"); #endregion string[] data = { userInfo.full_name, validcode }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "116831", data); if (retData["statusCode"].ToString() == "000000") { this.showmsg.Attributes["class"] = "showok"; this.showmsg.Visible = true; this.showmsg.InnerText = "发送成功"; userInfo.Password = viviLib.Security.Cryptography.MD5(validcode); viviapi.BLL.User.Factory.Update(userInfo, null); return; } else { this.showmsg.Attributes["class"] = "showno"; this.showmsg.Visible = true; this.showmsg.InnerText = "发送失败"; return; } } } #endregion else if (findmode == "2") { if (this.txtuseremail.Value != userInfo.Email) { this.showmsg.Attributes["class"] = "showno"; this.showmsg.Visible = true; this.showmsg.InnerText = "邮件地址不正确"; return; } else { string validcode = new Random().Next(100000, 999999).ToString(); userInfo.Password = viviLib.Security.Cryptography.MD5(validcode); viviapi.BLL.User.Factory.Update(userInfo, null); this.showmsg.InnerText = SendMail(validcode); this.showmsg.Visible = true; return; } } else if (findmode == "3") { if (this.txtanswer1.Value != userInfo.answer) { this.showmsg.Attributes["class"] = "showno"; this.showmsg.Visible = true; this.showmsg.InnerText = "问题答案不正确"; return; } else { string validcode = new Random().Next(100000, 999999).ToString(); userInfo.Password = viviLib.Security.Cryptography.MD5(validcode); viviapi.BLL.User.Factory.Update(userInfo, null); this.showmsg.Attributes["class"] = "showok"; this.showmsg.InnerText = "操作成功!新密码为" + validcode; this.showmsg.Visible = true; return; } } }
public override void OnLoad(HttpContext context) { string msg = ""; try { #region string phone = GetValue("phone"); string ValidateCode = GetValue("ValidateCode"); if (!string.IsNullOrEmpty(phone)) { if (string.IsNullOrEmpty(ValidateCode)) { msg = "验证码为空,请输入验证码"; } else { //验证验证码 if (context.Session["_ValidateCode"] == null) { msg = "验证码过期"; } else { string sessionCode = context.Session["_ValidateCode"].ToString(); if (sessionCode.ToLower() != ValidateCode.ToLower()) { msg = "验证码错误, 请重新输入!"; } else { if (phone == CurrentUser.Tel) { msg = "不能为原手机号码一样"; } else if (Validate.IsMobileNum(phone)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8aaf07085adadc12015adb64bea70074", "547a3c1801b04b6ab2ebedc5d7ed1694"); api.setAppId("8aaf07085adadc12015adb64c05a007b"); // api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); #endregion bool isupdate = (CurrentUser.IsPhonePass == 1); string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } if (isInit) { // Dictionary<string, object> retData = api.SendTemplateSMS(短信接收号码, 短信模板id, 内容数据); string[] data = { CurrentUser.full_name, validcode }; // string[] data = { CurrentUser.full_name, validcode }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "162881", data); if (retData["statusCode"].ToString() == "000000") { msg = "true"; } else { msg = classHelp.getDictionaryData(retData); } context.Session["_ValidateCode"] = null; } else { msg = "初始化失败"; } #region 原有的发送短信 //string result = SMS.SendSmsWithCheck(phone, smscontext, ""); //if (string.IsNullOrEmpty(result)) //{ // msg = "true"; //} //else //{ // msg = result; //} } //else if (Validate.IsMobileNum(phone)) //{ // bool isupdate = (CurrentUser.IsPhonePass == 1); // string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); // string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); // if (validcode == null) // { // validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); // WebCache.GetCacheService().AddObject(cacheKey, validcode); // } // string smscontext = ""; //string.Format("您的验证码是:{0}[{1}]", validcode, viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // if (isupdate) // smscontext = SMSTempSettings.SMS_Temp_Modify; // else // { // smscontext = SMSTempSettings.SMS_Temp_Authenticate; // } // if (!string.IsNullOrEmpty(smscontext)) // { // smscontext = smscontext.Replace("{@username}", CurrentUser.full_name); // smscontext = smscontext.Replace("{@sitename}", // viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // smscontext = smscontext.Replace("{@authcode}", validcode); // } // string result = SMS.SendSmsWithCheck(phone, smscontext, ""); // if (string.IsNullOrEmpty(result)) // { // msg = "true"; // } // else // { // msg = result; // } //} #endregion else { msg = "请输入正确的手机号码"; } } } } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAllSettle_Click(object sender, EventArgs e) { int success = 0; string resultStr = ""; string ids = Request.Form["TranNoList"]; if (string.IsNullOrEmpty(this.txtPassWord.Text)) { ShowMessageBox("请输入二级密码"); } else { if (!viviapi.BLL.ManageFactory.SecPwdVaild(this.txtPassWord.Text.Trim())) { ShowMessageBox("二级密码不正确"); } else { if (!string.IsNullOrEmpty(ids)) { foreach (string tranNo in ids.Split(',')) { viviapi.Model.Finance.Withdraw itemInfo = viviapi.BLL.Finance.Withdraw.Instance.GetModel(tranNo); if (itemInfo != null) { itemInfo.Paytime = DateTime.Now; bool result = viviapi.BLL.Finance.Withdraw.Instance.Complete(itemInfo); if (result == true) { success++; var UserInfo = viviapi.BLL.User.Factory.GetModel(itemInfo.Userid); if (UserInfo != null && !string.IsNullOrEmpty(UserInfo.Tel)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5515018a0f4015045e342b14990", "07c2d4f927a1443fb4ffffe158ee39b8"); api.setAppId("8a216da8567745c001568c78ae030d62"); #endregion string[] data = { UserInfo.full_name, itemInfo.Amount.ToString("f2") }; Dictionary <string, object> retData = api.SendTemplateSMS(UserInfo.Tel, "108968", data); //短信发送失败 if (retData["statusCode"].ToString() != "000000") { resultStr += "\n用户" + UserInfo.full_name + ",手机号:" + UserInfo.Tel + "通知短信发送失败.statusCode:" + retData["statusCode"] + ",statusMsg:" + retData["statusMsg"]; } } } } } AlertAndRedirect("成功处理" + success.ToString() + "笔" + resultStr); } else { ShowMessageBox("请选择要支付的记录!"); } } } }
public override void OnLoad(HttpContext context) { string msg = ""; try { #region string phone = GetValue("phone"); if (!string.IsNullOrEmpty(phone)) { if (phone == CurrentUser.Tel) { msg = "不能为原手机号码一样"; } else if (Validate.IsMobileNum(phone)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5515018a0f4015045e342b14990", "07c2d4f927a1443fb4ffffe158ee39b8"); // api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); #endregion bool isupdate = (CurrentUser.IsPhonePass == 1); string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } string smscontext = ""; //string.Format("您的验证码是:{0}[{1}]", validcode, viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); if (isupdate) { api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); } // smscontext = SMSTempSettings.SMS_Temp_Modify; else { api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); //smscontext = SMSTempSettings.SMS_Temp_Authenticate; } //if (!string.IsNullOrEmpty(smscontext)) //{ // smscontext = smscontext.Replace("{@username}", CurrentUser.full_name); // smscontext = smscontext.Replace("{@sitename}", // viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // smscontext = smscontext.Replace("{@authcode}", validcode); //} if (isInit) { // Dictionary<string, object> retData = api.SendTemplateSMS(短信接收号码, 短信模板id, 内容数据); string[] data = { "铭云支付商户-大宝", "100" }; // string[] data = { CurrentUser.full_name, validcode }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "87105", data); msg = classHelp.getDictionaryData(retData); } else { msg = "初始化失败"; } //string result = SMS.SendSmsWithCheck(phone, smscontext, ""); //if (string.IsNullOrEmpty(result)) //{ // msg = "true"; //} //else //{ // msg = result; //} } else { msg = "请输入正确的手机号码123"; } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
protected string Page_Load(long phone) { string ret = null; DateTime datetime = DateTime.Now; string Dtime = datetime.ToString("yyyy-MM-dd"); Random ran = new Random(); string verification= System.Guid.NewGuid().ToString().Substring(0, 6); //int verification = ran.Next(100000, 999999);//生成验证码 Session["verification"] = verification; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5514e1f2cc0014e1f6d2b1b008c", "74ea1d760e8f473ca9f218440b4ccd91"); api.setAppId("8a48b5514e236232014e2458322c0178"); try { if (isInit) { int minutes = 15; string[] dates = { verification.ToString(), minutes.ToString() };//验证码,时间 Dictionary<string, object> retData = api.SendTemplateSMS(phone.ToString(), "29292", dates);//短信接收号码,短信模板id,内容数据 ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Response.Write(ret); } return verification; }
/// <summary> /// 发送验证码 /// </summary> /// <param name="config">配置</param> /// <param name="receivePhone">接收手机号 多个逗号','隔开</param> /// <param name="info">内容 短信模板里 填充占位符的值</param> /// <returns></returns> public static SMSResposeBody SendVCodeSMS(SMSConfig config, string receivePhone, string[] info) { if (config == null) throw new ArgumentNullException("config"); if (string.IsNullOrWhiteSpace(receivePhone)) throw new ArgumentNullException("receivePhone"); if (info == null || info.Count() <= 0) throw new ArgumentNullException("info"); string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init(config.RestURL, config.RestPort); api.setAccount(config.ACCOUNTSID, config.AUTHTOKEN); api.setAppId(config.AppID); api.enabeLog(false); try { if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(receivePhone, config.VCodeTemplateID, info); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { throw exc; } SMSResposeBody body = new JavaScriptSerializer().Deserialize<SMSResposeBody>(ret); return body; }
private string sendYzm(string phone, string yyid, string[] arr) { string result = "0"; string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("aaf98f894e8a784b014e8b9aacc30280", "3c12c5c2d099444cbf42bed59067989d"); api.setAppId("8a48b5514e8a7522014e9098fef207d1"); try { if (isInit) { Dictionary<string, object> retData = api.SendTemplateSMS(phone, yyid, arr); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } if (ret.IndexOf("000000") > -1) result = "1"; return result; }
/// <summary> /// 获取验证码 /// </summary> /// <param name="tel">手机号</param> /// <param name="smsData">验证码,字符串数组形式</param> /// <param name="iCodeType">验证码类型1001登录验证码;1002修改密码</param> /// <param name="strModelNumber">模板类型1:登陆;2修改密码</param> /// <returns></returns> public string SendSms(string tel, string[] smsData, int iCodeType, string strModelNumber, string strVerifiCode) { string strRet = string.Empty; #region "短信" string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); string SMS_URL = ConfigurationManager.AppSettings["SMS_URL"].ToString().Trim(); string SMS_PORT = ConfigurationManager.AppSettings["SMS_PORT"].ToString().Trim(); string ACCOUNT_SID = ConfigurationManager.AppSettings["SMS_ACCOUNT_SID"].ToString().Trim(); string AUTH_TOKEN = ConfigurationManager.AppSettings["SMS_AUTH_TOKEN"].ToString().Trim(); string APP_ID = ConfigurationManager.AppSettings["SMS_APP_ID"].ToString().Trim(); string strModel = ConfigurationManager.AppSettings["SMS_MODEL_" + strModelNumber].ToString().Trim(); bool isInit = api.init(SMS_URL, SMS_PORT); api.setAccount(ACCOUNT_SID, AUTH_TOKEN); api.setAppId(APP_ID); try { if (isInit) { Dictionary <string, object> retData = api.SendTemplateSMS(tel, strModel, smsData); ret = getDictionaryData(retData); //短信发送成功! if (ret.Contains("成功")) { DateTime outTime = DateTime.Now.AddMinutes(5); string strSql = string.Format(@"insert into BASE_SMS (id, MOBILE_CODE, SECURITY_CODE, TIME_OUT, IS_USER, CODE_TYPE) values (:v_id, :v_mobile_code, :V_SECURITY_CODE, :V_TIME_OUT, :V_IS_USER, :V_CODE_TYPE)"); List <OracleParameter> aslgList = new List <OracleParameter>(); string strGuid = GUID; strRet = strGuid; aslgList.Add(new OracleParameter(":v_id", strGuid)); aslgList.Add(new OracleParameter(":v_mobile_code", tel)); aslgList.Add(new OracleParameter(":V_SECURITY_CODE", strVerifiCode)); aslgList.Add(new OracleParameter(":V_TIME_OUT", outTime)); aslgList.Add(new OracleParameter(":V_IS_USER", Convert.ToInt32(0))); aslgList.Add(new OracleParameter(":V_CODE_TYPE", iCodeType)); int ires = OracleHelper.ExecuteNonQuery(strSql, aslgList.ToArray()); if (ires <= 0) { throw new Exception("短信验证码插入失败!"); } } else { throw new Exception("验证码发送失败,超过发送次数!"); } } else { throw new Exception("短信发送,初始化失败"); } return(strRet); } catch (Exception exc) { throw new Exception("短信发送失败:" + exc.Message); } #endregion }