public ActionResult SendMobile_RechargeSum(Dictionary <string, string> queryvalues) { string Hour = queryvalues.ContainsKey("Hour") ? queryvalues["Hour"] : string.Empty; string HourInter = queryvalues.ContainsKey("HourInter") ? queryvalues["HourInter"] : "10"; string Money = queryvalues.ContainsKey("Money") ? queryvalues["Money"] : "0"; string Limit = queryvalues.ContainsKey("Limit") ? queryvalues["Limit"] :"0"; // 请根据实际 appid 和 appkey 进行开发,以下只作为演示 sdk 使用 log.Info("充值统计接受参数Hour" + Hour + ",Money" + Money + ",Limit" + Limit); int sdkappid = 1400023585; string appkey = "aa51e0fe315f7873094779bda1d715b8"; int tmplId = 9048; try { SmsSingleSender singleSender = new SmsSingleSender(sdkappid, appkey); List <string> templParams = new List <string>(); SmsMultiSenderResult multiResult; SmsMultiSender multiSender = new SmsMultiSender(sdkappid, appkey); //List<string> phoneNumbers = new List<string>() { // "15918716259" //}; List <string> phoneNumbers = new List <string>() { "13923666964", "13760368110", "13651452358", "13058199330", "15019431331", "13829601181", "13651452358" }; // 指定模板群发 // 假设短信模板内容为:测试短信,{1},{2},{3},上学。 templParams.Clear(); templParams.Add(HourInter); templParams.Add(Money); templParams.Add(Limit); multiResult = multiSender.SendWithParam("86", phoneNumbers, tmplId, templParams, "", "", ""); log.Info("multiResult:" + multiResult.result); int res = NoAuthBLL.UpdateRechargeSum(Convert.ToInt32(Hour)); log.Info("res:" + res); return(Content("1")); } catch (Exception e) { log.Info("充值统计接口错误" + e.Message); return(Content("0")); } }
public ActionResult SendSMS(Dictionary <string, string> queryvalues) { string account = "jiekou-clcs-13"; string password = "******"; int userid = queryvalues.ContainsKey("userid") ? Convert.ToInt32(queryvalues["userid"]) : -1; string mobile = queryvalues.ContainsKey("mobile") ? queryvalues["mobile"] : string.Empty; Random r = new Random(); int num = r.Next(100000, 999999); string sign = num.ToString(); string content = "亲爱的用户,您的手机验证码是" + sign + ",此验证码1分钟内有效,请尽快完成验证。"; string postStrTpl = "account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product=&extno="; UTF8Encoding encoding = new UTF8Encoding(); byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content)); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = postData.Length; Stream newStream = myRequest.GetRequestStream(); // Send the data. newStream.Write(postData, 0, postData.Length); newStream.Flush(); newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); if (myResponse.StatusCode == HttpStatusCode.OK) { StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string msg = reader.ReadToEnd(); //反序列化upfileMmsMsg.Text //保存数据 NoAuthBLL.AddSMS(userid, sign); return(Content("1", "string")); } else { //访问失败 return(Content("0", "string")); } }