Example #1
0
        /// <summary>
        ///  发送短信验证码。
        /// </summary>
        /// <param name="tel"></param>
        /// <param name="code"></param>
        public static void sendSMSCode(string tel,string code)
        {
            string serverIp = "api.ucpaas.com";
            string serverPort = "443";
            string account = "504d056eca8627dac2a7f77649244aa6";    //用户sid
            string token = "226db99dab9b85dcd598062a00be2a43";      //用户sid对应的token
            string appId = "693ec3ae294646e79ee1453bcdc4dde1";      //对应的应用id,非测试应用需上线使用
            string clientNum = "60000000000001";
            string clientpwd = "";
            string friendName = "";
            string clientType = "0";
            string charge = "0";
            string phone = "";
            string date = "day";
            uint start = 0;
            uint limit = 100;
            string toPhone = tel;                         //发送短信手机号码,群发逗号区分
            string templatedId = "13356";                               //短信模板id,需通过审核
            string param = code+",2";                                     //短信参数
            string verifyCode = "1234";
            string fromSerNum = "4000000000";
            string toSerNum = "4000000000";
            string maxallowtime = "60";

            UCSRestRequest.UCSRestRequest req = new UCSRestRequest.UCSRestRequest();

            req.init(serverIp, serverPort);
            req.setAccount(account, token);
            req.enabeLog(true);
            req.setAppId(appId);
            req.enabeLog(true);

            req.SendSMS(toPhone, templatedId, param);
        }
Example #2
0
        /// <summary>
        /// 创建验证
        /// </summary>
        /// <param name="type"></param>
        /// <param name="to"></param>
        /// <param name="verifyCode"></param>
        /// <param name="dateCreated"></param>
        public void Create(VerificationType type, string to)
        {
            string chkCode = string.Empty;

            //验证码的字符集,去掉了一些容易混淆的字符
            char[] character = { '2', '3', '4', '5', '6', '8', '9', 'a', 'b', 'd', 'e', 'f', 'h', 'k', 'm', 'n', 'r', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };
            Random rnd       = new Random();

            //生成验证码字符串
            for (int i = 0; i < 4; i++)
            {
                chkCode += character[rnd.Next(character.Length)];
            }
            Model.Verification entity = new Model.Verification()
            {
                Type = type, To = to, VerifyCode = chkCode, DateCreated = DateTime.Now
            };
            if (type == VerificationType.Phone)
            {
                UCSRestRequest.UCSRestRequest api = new UCSRestRequest.UCSRestRequest();
                string serverIp   = "api.ucpaas.com";
                string serverPort = "443";
                string account    = "e5bbac9f08b8900cb5c5e488f792cc0b"; //用户sid
                string token      = "3499976b631aed9120c1106d8b9dc694"; //用户sid对应的token
                string appId      = "bbcfd83149ab4016a89f9208f8a41b50"; //对应的应用id,非测试应用需上线使用

                api.init(serverIp, serverPort);
                api.setAccount(account, token);
                api.enabeLog(true);
                api.setAppId(appId);
                api.enabeLog(true);

                //短信
                api.SendSMS(entity.To, "48224", entity.VerifyCode);
            }
            dal.Create(entity);
        }