コード例 #1
0
    public string getYanzheng(string phone)
    {
        ITopClient client = new DefaultTopClient(urlstr, appkey, secret);
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        Random rd = new Random();

        //Response.Write(rd.Next().ToString().Substring(0, 6));
        //string scode = rd.Next().ToString().Substring(1, 4);//随机验码
        req.Extend          = "123456";
        req.SmsType         = "normal";
        req.SmsFreeSignName = "科技成果交易网";
        //req.SmsParam = "{\"code\":\"1234\",\"product\":\"alidayu\"}";
        req.SmsParam = "{\"name\":\"" + phone + "\"}";
        req.RecNum   = phone;                 //手机号 //13701122500
        //req.SmsTemplateCode = "SMS_63820762";
        req.SmsTemplateCode = "SMS_94215014"; // "SMS_72830026";
        AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

        //Response.Write(rsp.Body);
        if (rsp.Body.Contains("true"))
        {
            //Response.Write("sms send true" + scode);
            return(phone);
        }
        else
        {
            //Response.Write("sms send false:" + rsp.Body + scode);
            return("error");
        }
        //0107285666712^1109815260840trueeibuufdkzges
        //0107285744472^1109815397495true439gth0asr0y
        //0107286008344^1109815661785true3gtqrtumy02l
    }
コード例 #2
0
ファイル: VCode.cs プロジェクト: realyrare/GamePlay
 /// <summary>
 /// 阿里大鱼api验证码发送
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="outCode"></param>
 /// <returns></returns>
 public static string SendVCode(string mobile, string outCode)
 {
     try
     {
         ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "23450194", "52b5a70bc10ba56ccfe6e50bdb9fa8d4");
         AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
         req.Extend          = "";
         req.SmsType         = "normal";
         req.SmsFreeSignName = "爽赞游戏网"; //签名,将来要改
         req.SmsParam        = "{\"code\":\"" + outCode + "\",\"product\":\"爽赞游戏网(www.shuangzan.com)\"}";
         //  req.SmsFreeSignName = "躺鹰网"; //签名,将来要改
         // req.SmsParam = "{\"code\":\"" + outCode + "\",\"product\":\"躺鹰网(www.tangying.com)\"}";
         req.RecNum          = mobile;
         req.SmsTemplateCode = "SMS_14720884"; //短信模板
         AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
         if (rsp.Result.Success)
         {
             return("ok,验证码发送成功");
         }
         else
         {
             return("no,验证码发送失败");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
ファイル: SMSNotifier.cs プロジェクト: ztxyzu/wx_public
        public List <string> Send(NotifierData msg, List <string> userIds)
        {
            DAL.EmpModels.EmpContext emp       = new DAL.EmpModels.EmpContext();
            List <string>            successes = new List <string>();

            ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, secret);
            var        users  = emp.Users.Where(x => userIds.Contains(x.Id)).ToList();

            if (users.Count() == 0)
            {
                return(successes);
            }

            foreach (var u in users)
            {
                try
                {
                    AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                    req.SmsType         = "normal";
                    req.SmsFreeSignName = msg.SignName;
                    req.SmsParam        = "{\"source\":\"\",\"reason\":\"" + msg.Msg.Subject + "\",\"alert\":\"\"}";
                    req.RecNum          = "" + u.PhoneNumber;
                    req.SmsTemplateCode = msg.TemplateCode;
                    AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                    successes.Add(u.Id);
                }
                catch (Exception ex)
                {
                    MyConsole.log(ex, "短信发送异常");
                }
            }
            return(successes);
        }
コード例 #4
0
        public static bool Send(string phone, string data)
        {
            bool isSuccess = true;

            try
            {
                string     url    = m_config.AppSettings.Settings["SmsUrl"].Value;
                string     appkey = m_config.AppSettings.Settings["SmsAppkey"].Value;
                string     secret = m_config.AppSettings.Settings["SmsSecret"].Value;;
                ITopClient client = new DefaultTopClient(url, appkey, secret);
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                req.Extend          = "";
                req.SmsType         = "normal";
                req.SmsFreeSignName = "预付费管理系统";
                req.SmsParam        = data;
                req.RecNum          = phone;
                req.SmsTemplateCode = "SMS_20160057";
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                Match match = Regex.Match(rsp.Body, "<success>(.*?)</success>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (match.Success && match.Groups.Count > 1)
                {
                    isSuccess = Convert.ToBoolean(match.Groups[1].Value);
                }
            }
            catch
            {
                isSuccess = false;
            }

            return(isSuccess);
        }
コード例 #5
0
ファイル: SmsHelper.cs プロジェクト: chengliangkaka/Prepaid
        public static bool Send(string phone, string data)
        {
            bool isSuccess = true;
            try
            {
                string url = m_config.AppSettings.Settings["SmsUrl"].Value;
                string appkey = m_config.AppSettings.Settings["SmsAppkey"].Value;
                string secret = m_config.AppSettings.Settings["SmsSecret"].Value; ;
                ITopClient client = new DefaultTopClient(url, appkey, secret);
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                req.Extend = "";
                req.SmsType = "normal";
                req.SmsFreeSignName = "预付费管理系统";
                req.SmsParam = data;
                req.RecNum = phone;
                req.SmsTemplateCode = "SMS_20160057";
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                Match match = Regex.Match(rsp.Body, "<success>(.*?)</success>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (match.Success && match.Groups.Count > 1)
                    isSuccess = Convert.ToBoolean(match.Groups[1].Value);
            }
            catch
            {
                isSuccess = false;
            }

            return isSuccess;
        }
コード例 #6
0
ファイル: SMSNotifier.cs プロジェクト: ztxyzu/wx_public
        public string  Send(NotifierData msg, string userId)
        {
            DAL.EmpModels.EmpContext emp = new DAL.EmpModels.EmpContext();
            ITopClient client            = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, secret);

            try
            {
                var u = emp.Users.FirstOrDefault(x => x.Id == userId);
                if (u == null)
                {
                    return(null);
                }
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                req.SmsType         = "normal";
                req.SmsFreeSignName = msg.SignName;
                req.SmsParam        = "{\"source\":\"\",\"reason\":\"" + msg.Msg.Subject + "\",\"alert\":\"\"}";
                req.RecNum          = "" + u.PhoneNumber;
                req.SmsTemplateCode = msg.TemplateCode;
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                return(rsp.Body);
            }
            catch (Exception ex)
            {
                MyConsole.log(ex, "短信发送异常");
            }
            return(null);
        }
コード例 #7
0
        //发送验证码
        private string SendSecurityCode(string SecurityCode)
        {
            phoneNumber = this.user_PhoneNumber.Value.ToString().Trim();
            string result = "";

            if (MetarnetRegex.IsMobilePhone(phoneNumber))
            {
                ITopClient client = new DefaultTopClient(url, AppKey, Security);

                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

                req.Extend = "123456";

                req.SmsType = "normal";

                req.SmsFreeSignName = "注册验证";
                //    req.SmsParam = String.Format("{\"code\":\"1234\",\"product\":\"打堆云打印\"}", SecurityCode);// "{\"code\":\"1234\",\"product\":\"打堆云打印\"}";
                req.SmsParam        = "{\"code\":\"" + SecurityCode + "\",\"product\":\"打堆云打印\"}";
                req.RecNum          = phoneNumber;
                req.SmsTemplateCode = "SMS_3125049";
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                result = rsp.Body;
            }
            return(result);
        }
コード例 #8
0
    /// <summary>
    /// 发送短信
    /// </summary>
    /// <param name="extend">公共回传参数(可选,如会员ID)</param>
    /// <param name="smsType">短信类型,默认值:normal</param>
    /// <param name="smsSignName">短信签名,必须是阿里大鱼管理中心可用签名</param>
    /// <param name="smsParas">短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开,示例:{"code":"1234","product":"alidayu"}</param>
    /// <param name="telNo">短信接收号码(11位手机号码,不能加0或+86)群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码</param>
    /// <param name="smsTemplateCode">短信模板ID,必须是阿里大鱼管理中心可用模板ID</param>
    /// <returns></returns>
    public static string Send(string extend, string smsType, string smsSignName, string smsParas, string telNo, string smsTemplateCode)
    {
        string ret = "";

        try
        {
            ITopClient client = new DefaultTopClient(Furl, Fappkey, Fappsecret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            req.Extend          = extend;
            req.SmsType         = smsType;
            req.SmsFreeSignName = smsSignName;
            req.SmsParam        = smsParas;
            req.RecNum          = telNo;
            req.SmsTemplateCode = smsTemplateCode;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            if (rsp.IsError)
            {
                ret = rsp.ErrMsg;
                if (ret == "")
                {
                    ret = rsp.SubErrMsg;
                }
                if (ret == "")
                {
                    ret = "发送失败";
                }
            }
        }
        catch (Exception ex)
        {
            ret = "发送失败:" + ex.Message;
        }
        return(ret);
    }
コード例 #9
0
        /// <summary>
        /// 【阿里大鱼】执行发送阿里大鱼短信方法
        /// </summary>
        /// <param name="mobile">手机号</param>
        /// <param name="smsParam">短信模板变量</param>
        /// <param name="smsTemplateCode">短信模板ID</param>
        /// <returns>通过判断调用借口返回的错误信息来判断是否成功</returns>
        public static string SendSmsByAli(string mobile, string smsParam, int smsTemplateCode)
        {
            var        serverUrl = ConfigUtil.ServerUrl_ali;
            var        appKey    = ConfigUtil.Appkey_ali;
            var        appSecret = ConfigUtil.AppSecret_ali;
            ITopClient client    = new DefaultTopClient(serverUrl, appKey, appSecret);
            // 构建阿里大鱼短信实体对象
            var req = new AlibabaAliqinFcSmsNumSendRequest
            {
                // 公共回传参数,在“消息返回”中会透传回该参数
                Extend = "1234",
                // 短信类型,传入值写入normal
                SmsType = "normal",
                // 短信签名
                SmsFreeSignName = ConfigUtil.SmsFreeSignName_ali,
                // 短信模板变量
                SmsParam = smsParam,
                // 短信接收号码
                RecNum = mobile,
                // 短信模板ID
                SmsTemplateCode = string.Format("SMS_{0}", smsTemplateCode.ToString())
            };

            var rsp = client.Execute(req);

            return(rsp.ErrMsg);
        }
コード例 #10
0
        public bool Send(string m, string code, int time, out string errMsg)
        {
            ITopClient client = new DefaultTopClient(APIURL, APPKEY, SECRET);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = m;
            req.SmsType         = "normal";
            req.SmsFreeSignName = "启点基因";
            req.SmsParam        = "{\"code\":\"" + code + "\",\"product\":\"\",\"time\":\" " + time + "\"}";
            req.RecNum          = m;
            req.SmsTemplateCode = "SMS_15870205";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            string result = rsp.Body;

            errMsg = string.Empty;
            if (rsp.Result != null && rsp.Result.Success)
            {
                return(true);
            }
            else
            {
                errMsg = rsp.SubErrMsg;
                return(false);
            }
        }
コード例 #11
0
ファイル: SendMessage.aspx.cs プロジェクト: amiezhang/Youbang
 protected void Button1_Click(object sender, EventArgs e)
 {
     string url = " 	http://gw.api.taobao.com/router/rest";
     string appkey = "23303886";
     string secret = "1adacc8621fdf01eab3cf627ccc020b2";
     ITopClient client = new DefaultTopClient(url, appkey, secret);
     AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
     req.Extend = "123456";
     req.SmsType = "normal";
     req.SmsFreeSignName = "活动验证";
     req.SmsParam = "yigdsaf";
     req.RecNum = "18819257475";
     req.SmsTemplateCode = "SMS_4970603";
     try
     {
         AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
         Console.WriteLine(rsp.Body);
         Response.Write("<script>alert('成功')</script>");
     }
     catch
     {
         Response.Write("<script>alert('shibai')</script>");
     }
    
 }
コード例 #12
0
        /// <summary>
        /// 得到状态
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        protected override string GetSendStatus(MobileEntity info)
        {
            var builder = new StringBuilder("{");

            builder.AppendFormat("code:'{0}'", info.Body.Replace("'", "''"));
            builder.Append("}");
            string     url                       = Setting.Url;
            string     appKey                    = Setting.AppKey;
            string     appSecret                 = Setting.AppSecret;
            string     smsFreeSignName           = Setting.SmsFreeSignName;
            string     smsType                   = Setting.SmsType;
            string     smsTemplateCode           = Setting.SmsTemplateCode;
            ITopClient client                    = new DefaultTopClient(url, appKey, appSecret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend  = "";
            req.SmsType = smsType;
            //单引号转义.
            req.SmsParam        = builder.ToString();
            req.RecNum          = string.Join(",", info.ToMobiles);
            req.SmsTemplateCode = smsTemplateCode;
            req.SmsFreeSignName = smsFreeSignName;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            return(rsp.SerializeJson());
        }
コード例 #13
0
        public JsonResult SendRandomCodeToMobile(string phone, string username = "", int type = 0)
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "好油菜";
            var randomCode = GetID();

            //req.SmsParam = "{name:'stone',number:'3345'}";
            req.SmsParam        = "{name:'" + username + "',number:'" + randomCode + "'}";
            req.RecNum          = phone;
            req.SmsTemplateCode = "SMS_36290127";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //存储结果,发送时间,随机数和手机号
            var code = new PhoneCode
            {
                Mobile        = phone,
                Code          = randomCode.ToString(),
                Successed     = !rsp.IsError,
                ErrorCode     = rsp.ErrCode,
                ErrorMsg      = rsp.ErrMsg,
                PhoneCodeType = (PhoneCodeType)type
            };

            _phoneCodeSerice.Insert(code);
            if (rsp.IsError)
            {
                Logger.Debug(rsp.ErrCode + " " + rsp.ErrMsg);
            }
            return(Json(new { success = !rsp.IsError, message = rsp.ErrMsg, code = rsp.ErrCode }, JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
ファイル: SMSSendClient.cs プロジェクト: yajore/juncheng
        public static string Send(string mobiles, string param, int smstypeid)
        {
            string result = "-1,发送短信失败";
            var    req    = new AlibabaAliqinFcSmsNumSendRequest();

            try
            {
                if (sms_template.ContainsKey(smstypeid) == false)
                {
                    throw new System.Exception("短信类型不正确");
                }
                var client = new DefaultTopClient(sms_url, sms_appkey, sms_secret);
                req.SmsType         = "normal";
                req.SmsFreeSignName = sms_sign;
                req.SmsParam        = param;
                req.RecNum          = mobiles;
                req.SmsTemplateCode = sms_template[smstypeid];
                var rsp = client.Execute(req);
                if (rsp.IsError == false)
                {
                    result = "0,OK";
                }
                else
                {
                    result = rsp.ErrCode + "," + rsp.ErrMsg;
                }
            }
            catch (System.Exception ex)
            {
                result = "-1," + ex.Message;
                Logger.WriteException("【阿里大鱼短信接口】", ex, req);
            }

            return(result);
        }
コード例 #15
0
        public int Send(string phone, string Content)
        {
#if !FB
            return(0);
#endif
            ITopClient client = new DefaultTopClient(App_Url, App_Key, App_Secret, "json");
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            req.Extend          = "";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "番茄卷";
            req.SmsParam        = "{\"code\":\"" + Content + "\"}";
            req.RecNum          = phone;
            req.SmsTemplateCode = "SMS_143711741";
            //if (type == SMSType.CODE)
            //    req.SmsTemplateCode = "SMS_67180723";
            //else if (type == SMSType.SMS)
            //    req.SmsTemplateCode = "SMS_67125710";
            //else if (type == SMSType.TEST)
            //{
            //    req.SmsFreeSignName = "注册验证";
            //    req.SmsTemplateCode = "SMS_671355717";
            //    req.SmsParam = "{\"code\":\"" + Content + "\",\"product\":\"百业宝\"}";
            //}
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            resultMsg = rsp.Body;
            if (rsp.IsError)
            {
                return(int.Parse(rsp.ErrCode));
            }
            return(0);
        }
コード例 #16
0
        public static bool SendCodeByAliDaYu(string mobile, int code, out string errorMessage)
        {
            errorMessage = null;
            try
            {
                ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", ConfigManager.SystemConfigInfo.SmsAliDaYuAppKey, ConfigManager.SystemConfigInfo.SmsAliDaYuAppSecret);
                var        req    = new AlibabaAliqinFcSmsNumSendRequest
                {
                    SmsType         = "normal",
                    SmsFreeSignName = ConfigManager.SystemConfigInfo.SmsAliDaYuSignName,
                    SmsParam        = "{code:'" + code + "'}",
                    RecNum          = mobile,
                    SmsTemplateCode = ConfigManager.SystemConfigInfo.SmsAliDaYuCodeTplId
                };

                var rsp    = client.Execute(req);
                var retval = rsp.Body;
                if (!retval.Contains("error_response"))
                {
                    return(true);
                }
                errorMessage = RegexUtils.GetInnerContent("msg", retval);
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }
            return(false);
        }
コード例 #17
0
        public static string AliSendMsg(string mobile, string randcode, string modelid, bool israndcode = true)
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret);

            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "测试";


            if (!israndcode)
            {
                req.SmsParam = "{name:'" + randcode + "'}";
            }
            else
            {
                req.SmsParam = "{number:'" + randcode + "'}";
            }
            req.RecNum          = mobile;
            req.SmsTemplateCode = modelid;

            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            var body = rsp.Body;

            return(body);
        }
コード例 #18
0
        /// <summary>
        /// 通知预警
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="room"></param>
        /// <param name="deviceName"></param>
        /// <returns></returns>
        public static string NotifyDanger(string mobile, string room, string deviceName)
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret);

            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "易指控";

            /*
             * ${name}向您发起了一笔交易请求,您的初始密码是${password}
             */

            //req.SmsParam = "{'room:'"+room+ ",'device:'"+deviceName+"}";
            req.SmsParam = "{room:'" + room + "',device:'" + deviceName + "'}";

            req.RecNum          = mobile;
            req.SmsTemplateCode = "SMS_151995664";

            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            var body = rsp.Body;

            return(body);
        }
コード例 #19
0
        public ActionResult UserGetPass(string mobile, string code)
        {
            var model = PersonalUserBll.UserGetPass(mobile, new Random().Next(100000, 999999).ToString());

            try
            {
                ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "23450194", "52b5a70bc10ba56ccfe6e50bdb9fa8d4");
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                req.Extend          = "";
                req.SmsType         = "normal";
                req.SmsFreeSignName = "爽赞网"; //签名,将来要改
                req.SmsParam        = "{\"code\":\"" + model.Pass + "\",\"product\":\"爽赞\"}";
                req.RecNum          = mobile;
                req.SmsTemplateCode = "SMS_35430038"; //短信模板

                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

                if (rsp.Result.Success)
                {
                    return(Json(new { success = "true", str = "验证码发送成功" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = "false", str = "验证码发送失败" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e) { return(Json(new { success = "false", str = "短信发送失败,原因未知" + e.Message }, JsonRequestBehavior.AllowGet)); }
        }
コード例 #20
0
        private bool sendphone(String phoneNum)
        {
            if (flag == 1) return false;
            else flag = 1;
            //生成验证码
            System.Random Random = new System.Random();
            int Result = Random.Next(1000, 9999);
            String codeNum = Result.ToString();

            //下面是发送短信验证码的代码,在这之前需要引入TopSdk.dll
            ITopClient client = new DefaultTopClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            req.Extend = "";
            req.SmsType = "normal";
            req.SmsFreeSignName = "Csharp作业";
            req.SmsParam = "{name:'" + "先生" + "',codeNum:'" + codeNum + "'}";
            req.RecNum = phoneNum;
            req.SmsTemplateCode = "SMS_11030283";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //Console.WriteLine(rsp.Body);

            Session["PHONE_CHECK_NUM"] = codeNum;

            return true;
        }
コード例 #21
0
ファイル: SMSAPI.cs プロジェクト: radtek/crm
        /// <summary>
        /// 阿里大鱼
        /// </summary>
        /// <param name="pSign"></param>
        /// <param name="pSMSContent"></param>
        /// <param name="pMobileNO"></param>
        /// <param name="pSmsTemplateCode"></param>
        /// <returns></returns>
        private static AlibabaAliqinFcSmsNumSendResponse AlidatySendMessage(string pSign, string pSMSContent, string pMobileNO, string pSmsTemplateCode)
        {
            string appKey = WebConfigurationManager.AppSettings["AlidayuAppKey"].ToString();
            string secret = WebConfigurationManager.AppSettings["AlidayuSecret"].ToString();
            string url    = WebConfigurationManager.AppSettings["AlidayuURL"].ToString();
            //短信发送日志
            SMSSendBLL bll = new SMSSendBLL(new JIT.Utility.BasicUserInfo());

            ITopClient client = new DefaultTopClient(url, appKey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.SmsType         = "normal";
            req.SmsFreeSignName = pSign;     //签名
            req.SmsParam        = pSMSContent;
            req.RecNum          = pMobileNO; //手机号
            req.SmsTemplateCode = pSmsTemplateCode;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            string[] temp = pMobileNO.Split(',');
            foreach (var i in temp)
            {
                var entity = new SMSSendEntity()
                {
                    MobileNO = i,
                    Sign     = pSign,
                };

                if (rsp.Result != null)
                {
                    entity.Status            = 1;
                    entity.SendCount         = (entity.SendCount ?? 0) + 1;
                    entity.RegularlySendTime = DateTime.Now;
                    var debug = new DebugLogInfo()
                    {
                        Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, entity.MobileNO, rsp.Result.Msg, rsp.Result.ErrCode)
                    };
                    Loggers.Debug(debug);
                }
                else
                {
                    entity.SendCount = (entity.SendCount ?? 0) + 1;
                    rsp.Result       = new BizResult()
                    {
                        ErrCode = rsp.ErrCode,
                        Msg     = rsp.SubErrMsg,
                        Success = false,
                    };
                    var debug = new DebugLogInfo()
                    {
                        Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, entity.MobileNO, rsp.SubErrCode, rsp.ErrCode)
                    };
                    Loggers.Debug(debug);
                }
                //保存数据库
                bll.Create(entity);
            }

            return(rsp);
        }
コード例 #22
0
 /// <summary>
 /// 发送验证码短信
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="code"></param>
 /// <param name="errorMsg"></param>
 /// <returns></returns>
 public static bool SendSMSCode(string mobile, string code, out string errorMsg)
 {
     try
     {
         if (DaYuConfig.IsSendVerifyCode == true)
         {
             #region 验证码短信流量控制
             var oldTime = DateTime.Now.AddMinutes(-DaYuConfig.SendVerifyCodeLimitMinute);
             if (SendVerifyCodeTimeList.Count > DaYuConfig.SendVerifyCodeLimitCount)
             {
                 //移除旧的发送时间记录
                 var oldTimeList = SendVerifyCodeTimeList.Where(o => o < oldTime).ToList();
                 if (oldTimeList != null && oldTimeList.Count > 0)
                 {
                     foreach (var item in oldTimeList)
                     {
                         SendVerifyCodeTimeList.Remove(item);
                     }
                 }
                 //判断流量是否超过限额
                 if (SendVerifyCodeTimeList.Count > DaYuConfig.SendVerifyCodeLimitCount)
                 {//超过限额,关闭短信功能,并发短信通知开发人员
                     string notifyErrorMsg = string.Empty;
                     SendNotifySMS(DaYuConfig.DeveloperMobile, DaYuConfig.VerifyCodeSMSExceptionTemplate, out notifyErrorMsg);
                     DaYuConfig.IsSendVerifyCode = false;
                     errorMsg = "短信流量达到限额限制,短信接口已关闭";
                     return(false);
                 }
             }
             #endregion
             ITopClient client = new DefaultTopClient(DaYuConfig.Url, DaYuConfig.AppKey, DaYuConfig.AppSecret);
             AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
             req.Extend          = mobile;
             req.SmsType         = "normal";
             req.SmsFreeSignName = DaYuConfig.SMSSignName;
             req.SmsParam        = (new { code = code }).ToJson();
             req.RecNum          = mobile;
             req.SmsTemplateCode = DaYuConfig.SMSCodeCommonTemplate;
             AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
             errorMsg = rsp.SubErrMsg;
             if (!rsp.IsError)
             {//短信发送成功,记录下短信发送时间
                 SendVerifyCodeTimeList.Add(DateTime.Now);
             }
             return(!rsp.IsError);
         }
         else
         {
             errorMsg = "短信流量达到限额限制,短信接口已关闭";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errorMsg = "发送短信异常";
         return(false);
     }
 }
コード例 #23
0
        public ActionResult GetCode(string mobile)
        {
            string realIp = "";

            if (mobile.Length != 11)
            {
                return(Json(new { success = "false", str = "手机号码长度不正确" }, JsonRequestBehavior.AllowGet));
            }
            if (mobile.ToString() == null)
            {
                return(Json(new { success = "false", str = "手机号码不正确" }, JsonRequestBehavior.AllowGet));
            }
            Random r     = new Random();
            string code2 = r.Next(100000, 999999).ToString();
            //往数据库发送验证码,手机号
            var code = PersonalUserBll.SendVCode(mobile, code2, realIp);

            if (code.OutCode != null)
            {
                try
                {
                    ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "23450194", "52b5a70bc10ba56ccfe6e50bdb9fa8d4");
                    AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                    req.Extend          = "";
                    req.SmsType         = "normal";
                    req.SmsFreeSignName = "爽赞游戏网"; //签名,将来要改
                    req.SmsParam        = "{\"code\":\"" + code.OutCode + "\",\"product\":\"爽赞游戏网(www.shuangzan.com)\"}";
                    req.RecNum          = mobile;
                    req.SmsTemplateCode = "SMS_14720884"; //短信模板
                    //  CS.Config.SaveErr(req.SmsParam);
                    AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                    // CS.Config.SaveErr(rsp.Body);
                    if (rsp.Result.Success)
                    {
                        return(Json(new { success = "true", str = "验证码发送成功" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //CS.Config.SaveErr(rsp.Body);
                        return(Json(new { success = "true", str = "验证码发送失败" }, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception e)
                {
                    return(Json(new { success = "false", str = "短信发送失败,原因未知" + e.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = "false", str = "您的验证码短信仍在30分钟有效期内" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #24
0
ファイル: Helper.cs プロジェクト: nEdAy/Shepherd-deprecated
        public string getMessage(string extend, string sms_free_sign_name, string rec_num, string sms_template_code)
        {
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = extend;
            req.SmsType         = "normal";
            req.SmsFreeSignName = sms_free_sign_name;
            req.RecNum          = rec_num;
            req.SmsTemplateCode = sms_template_code;
            AlibabaAliqinFcSmsNumSendResponse response = topClient.Execute(req);

            return(response.Body);
        }
コード例 #25
0
        private static string SMSPWD       = "gs2002";                                     //短信接口用户密码 固定值

        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="serverUrl">短信服务url</param>
        /// <param name="appKey">appKey</param>
        /// <param name="appSecret">appSecret</param>
        /// <param name="format">数据格式,一般是json</param>
        /// <param name="smsType">短信类型,传入值请填写normal</param>
        /// <param name="smsFreeSignName">签名</param>
        /// <param name="smsParam">短信模板参数变量  :  {\"code\":\"1234\",\"product\":\"alidayu\"}</param>
        /// <param name="recNum">短信接收号码。支持单个或多个手机号码,传入号码为11位手机号码,不能加0或+86。群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码。示例:18600000000,13911111111,13322222222</param>
        /// <param name="smsTemplateCode">短信模板ID</param>
        /// <returns></returns>
        public static Result <int> SendMessageByAlidayuSms(string serverUrl, string appKey, string appSecret, string format, string smsType, string smsFreeSignName, string smsParam, string recNum, string smsTemplateCode)
        {
            Result <int> result = new Result <int>();

            try
            {
                ITopClient client = new DefaultTopClient(serverUrl, appKey, appSecret, format);
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                //req.Extend = "";
                req.SmsType         = smsType;
                req.SmsFreeSignName = smsFreeSignName;
                req.SmsParam        = smsParam;
                req.RecNum          = recNum;
                req.SmsTemplateCode = smsTemplateCode;
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                try
                {
                    if (rsp.Result != null && rsp.Result.Success)
                    {
                        result.Data = 1;
                        result.Flag = EResultFlag.Success;
                    }
                    else
                    {
                        throw new Exception(rsp.Body);
                    }
                }
                catch (Exception rspEx)
                {
                    result.Data = -1;
                    result.Flag = EResultFlag.Failure;
                    if (rsp.SubErrCode != null)
                    {
                        throw new Exception(GetErrorMesage(rsp.SubErrCode));
                    }
                    else
                    {
                        throw new Exception(string.Format("发送短信失败,错误信息:{0}", rspEx.Message));
                    }
                }
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "SendMessageByAlidayu");
            }

            return(result);
        }
コード例 #26
0
ファイル: Sms.cs プロジェクト: radtek/CoinsPro
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="appkey"></param>
        /// <param name="secret"></param>
        /// <param name="SmsFreeSignName">短信签名,传入的短信签名必须是在阿里大于“管理中心-短信签名管理”中的可用签名。如“阿里大于”已在短信签名管理中通过审核,则可传入”阿里大于“(传参时去掉引号)作为短信签名。短信效果示例:【阿里大于】欢迎使用阿里大于服务。</param>
        /// <param name="SmsParam">短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开。示例:针对模板“验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”,传参时需传入{"code":"1234","product":"alidayu"}</param>
        /// <param name="RecNum">短信接收号码。支持单个或多个手机号码,传入号码为11位手机号码,不能加0或+86。群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码。示例:18600000000,13911111111,13322222222</param>
        /// <param name="SmsTemplateCode">短信模板ID,传入的模板必须是在阿里大于“管理中心-短信模板管理”中的可用模板。示例:SMS_585014</param>
        /// <param name="Extend">公共回传参数,在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,在消息返回时,该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用</param>
        /// <returns></returns>
        public BizResult Send(string appkey, string secret, string SmsFreeSignName, string SmsParam, string RecNum, string SmsTemplateCode, string Extend = "", string url = "https://eco.taobao.com/router/rest")
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret, "json");
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = Extend;
            req.SmsType         = "normal";
            req.SmsFreeSignName = SmsFreeSignName;
            req.SmsParam        = SmsParam;
            req.RecNum          = RecNum;
            req.SmsTemplateCode = SmsTemplateCode;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            return(rsp.Result);
        }
コード例 #27
0
    /// <summary>
    ///  调用阿里大于模板短信接口
    /// </summary>
    /// <param name="url"></param>
    /// <param name="appKey"></param>
    /// <param name="secret"></param>
    /// <param name="toPhoneNumber"></param>
    /// <returns></returns>
    public string AliSMS(string url, string appKey, string secret, string toPhoneNumber)
    {
        ITopClient client = new DefaultTopClient(url, appKey, secret);
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

        req.Extend          = "";
        req.SmsType         = "normal";
        req.SmsFreeSignName = "";
        req.SmsParam        = "";
        req.RecNum          = toPhoneNumber;
        req.SmsTemplateCode = "";
        AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

        return(rsp.Body);
    }
コード例 #28
0
ファイル: AliDaYuSMS.cs プロジェクト: guzhaoyang/AutoMapper
        /// <summary>
        ///  发短信通用接口
        /// </summary>
        /// <param name="extend">公共回传参数,
        /// 在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,在消息返回时,
        /// 该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用</param>
        /// <param name="smsFreeSignName">短信签名</param>
        /// <param name="code">短信模板ID</param>
        /// <param name="smsParam">短信模板变量“验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”,
        /// 传参时需传入{"code":"1234","product":"alidayu"}</param>
        /// <param name="mobile">接收的手机号码,群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码。</param>
        /// <returns>Json格式</returns>
        public static string SendSms(string extend, string smsFreeSignName, string code, string smsParam, string mobile)
        {
            ITopClient client = new DefaultTopClient(Url, AppKey, AppSecret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = extend;
            req.SmsType         = "normal";
            req.SmsFreeSignName = smsFreeSignName;
            req.SmsParam        = smsParam;
            req.RecNum          = mobile;
            req.SmsTemplateCode = code;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            return(rsp.SubErrMsg);
        }
コード例 #29
0
ファイル: SMS.cs プロジェクト: ljsheng1984/ZBSJ
        /// <summary>
        /// 发送发短息
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="msg">短信模版</param>
        /// <param name="json">参数</param>
        public static string postsend(string phone, string msg, string json)
        {
            ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "23334148", "521968d60abc9ca99aa44018248c2788", "json");
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "123456";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "ING少儿英语";
            req.SmsParam        = json;
            req.RecNum          = phone;
            req.SmsTemplateCode = msg;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            return(rsp.Body);
        }
コード例 #30
0
ファイル: IdentityConfig.cs プロジェクト: 51jzl/Websites
        public Task SendAsync(IdentityMessage message)
        {
            ITopClient client = new DefaultTopClient("https://eco.taobao.com/router/rest", "23320955", "488aabf9a95adb4999f6a8e24a8ec928");
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "1";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "注册验证";
            req.SmsParam        = message.Body;
            req.RecNum          = message.Destination;
            req.SmsTemplateCode = message.Subject;
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            // 在此处插入 SMS 服务可发送短信。
            return(Task.FromResult(!rsp.IsError));
        }
コード例 #31
0
ファイル: topsdk_test.aspx.cs プロジェクト: radtek/cccc
    protected void Page_Load(object sender, EventArgs e)
    {
        divshow.InnerHtml = "";
        //阿里大鱼短信接口测试
        ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "23618633", "59833b957efba563d7221316c6921ec8");
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

        req.Extend          = "guid-xxxx";
        req.SmsType         = "normal";
        req.SmsFreeSignName = "镜海盟";
        req.SmsParam        = "{\"yzm\":\"1234\"}";
        req.RecNum          = "18663178263";
        req.SmsTemplateCode = "SMS_44350181";
        AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

        divshow.InnerHtml = rsp.ErrMsg;
    }
コード例 #32
0
        static public bool SendSMS(string receiver, string Subject, string Body)
        {
            ITopClient client = new DefaultTopClient("	http://gw.api.taobao.com/router/rest", "23332091", "398e14719c701a0c8f55ef99ca51f25f");
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "123456";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "水晶监视";
            var time = DateTime.Now.ToString("hh:mm");

            req.SmsParam        = "{\"name\":\" " + Subject.Replace("\"", "\\\"") + " \",\"time\":\" " + time + " \"}";
            req.RecNum          = receiver;
            req.SmsTemplateCode = "SMS_91795055";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);

            return(true);
        }
コード例 #33
0
        /// <summary>
        /// 补全账户信息
        /// </summary>
        public static string PaddingUserInfo(string SmsFreeSignName, string number, string mobile)
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend  = "";
            req.SmsType = "normal";
            //req.SmsFreeSignName = "测试";
            req.SmsFreeSignName = SmsFreeSignName;
            req.SmsParam        = "{number:'" + number + "'}";
            req.RecNum          = mobile;
            req.SmsTemplateCode = "SMS_60845304";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            var body = rsp.Body;

            return(body);
        }
コード例 #34
0
ファイル: WebForm1.aspx.cs プロジェクト: tiantiannet/zq
        protected void Button1_Click(object sender, EventArgs e)
        {
            String name = this.TextBox1.Text;//用户名
            String phoneNum = this.TextBox2.Text;//电话号
            //生成验证码
            System.Random Random = new System.Random();
            int Result = Random.Next(1000, 9999);
            codeNum = Result.ToString();

            //下面是发送短信验证码的代码,在这之前需要引入TopSdk.dll
            ITopClient client = new DefaultTopClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            req.Extend = "";
            req.SmsType = "normal";
            req.SmsFreeSignName = "Csharp作业";
            req.SmsParam = "{name:'" + name + "',codeNum:'" + codeNum + "'}";
            req.RecNum = phoneNum;
            req.SmsTemplateCode = "SMS_11030283";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //Console.WriteLine(rsp.Body);
        }
コード例 #35
0
ファイル: Sms.cs プロジェクト: julinn/LinnStudio
 /// <summary>
 /// 发送短信
 /// </summary>
 /// <param name="extend">公共回传参数(可选,如会员ID)</param>
 /// <param name="smsType">短信类型,默认值:normal</param>
 /// <param name="smsSignName">短信签名,必须是阿里大鱼管理中心可用签名</param>
 /// <param name="smsParas">短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开,示例:{"code":"1234","product":"alidayu"}</param>
 /// <param name="telNo">短信接收号码(11位手机号码,不能加0或+86)群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码</param>
 /// <param name="smsTemplateCode">短信模板ID,必须是阿里大鱼管理中心可用模板ID</param>
 /// <returns></returns>
 public static string Send(string extend, string smsType, string smsSignName, string smsParas,string telNo, string smsTemplateCode)
 {
     string ret = "";
     try
     {
         ITopClient client = new DefaultTopClient(Furl, Fappkey, Fappsecret);
         AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
         req.Extend = extend;
         req.SmsType = smsType;
         req.SmsFreeSignName = smsSignName;
         req.SmsParam = smsParas;
         req.RecNum = telNo;
         req.SmsTemplateCode = smsTemplateCode;
         AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
         if (rsp.IsError)
         {
             ret = rsp.ErrMsg;
             if (ret == "")
                 ret = rsp.SubErrMsg;
             if (ret == "")
                 ret = "发送失败";
         }
     }
     catch(Exception ex)
     {
         ret = "发送失败:"+ex.Message;
     }
     return ret;
 }