Ejemplo n.º 1
0
        /**
         * 成功获到取号码后业务处理
         * @param mobile
         */
        public void process(String mobile)
        {
            ///////////请在这里加上你需要的业务代码/////////////
            //这里加上 从第三方平台申请下发验证码短信 代码


            ///////////请在这里加上你需要的业务代码/////////////


            // 如果号码已被使用,调用addIgnore方法对号码进行加黑
            // addIgnore(mobile);


            // 确认第三方平台下发短信后,调getVcodeAndReleaseMobile接口获取验证码短信

            try
            {
                Thread.Sleep(5000); //休眠5秒后开始调用
            }
            catch { }

            long start = DateTimeExtensions.currentTimeMillis(); //开始获取时间
            GetVcodeAndReleaseMobileResp resp = null;

            while (DateTimeExtensions.currentTimeMillis() - start < getCodeTimeout) //如果获取验证码短信超过等待时间getCodeTimeout,将不再获取,并释放号码
            {
                resp = getVcodeAndReleaseMobile(mobile);
                if (resp.State) //获取到验证码,跳出
                {
                    break;
                }
                else
                {
                    //Console.WriteLine("未获取到验证码");
                    try
                    {
                        Thread.Sleep(5000);
                    }
                    catch { }
                }
            }
            //成功获取短信验证码
            if (resp != null && resp.State)
            {
                Console.WriteLine("获取验证码成功,号码:" + resp.Mobile + ";验证码短信:" + resp.VerifyCode);
            }
            else //未获取到验证码,释放号码
            {
                Console.WriteLine("获取到验证码短信失败,释放号码" + mobile);
                cancelSMSRecv(mobile);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取验证码并不再使用这个手机号
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="uid"></param>
        /// <param name="token"></param>
        /// <param name="author_uid"></param>
        /// <returns></returns>
        public GetVcodeAndReleaseMobileResp getVcodeAndReleaseMobile(String mobile,
                                                                     String uid, String token, String author_uid)
        {
            GetVcodeAndReleaseMobileResp resp = new GetVcodeAndReleaseMobileResp();
            String result = "";

            try
            {
                result = send.HttpPost(url,
                                       "action=getVcodeAndReleaseMobile&uid=" + uid + "&token="
                                       + token + "&mobile=" + mobile + "&author_uid="
                                       + author_uid);

                String[] reset = result.Split('|');
                if (reset.Length >= 2 && isNumber(reset[0]))
                {
                    resp.State      = true;
                    resp.Mobile     = reset[0];
                    resp.VerifyCode = reset[1];
                    resp.Result     = result;
                }
                else
                {
                    resp.State  = false;
                    resp.Result = result;
                }

                info(
                    "获取验证码并不再使用这个手机号,mobile:" + mobile + ",uid:"
                    + uid + ",token:" + token + ",author_uid:" + author_uid + ",返回:"
                    + result + ",state:" + resp.State + ",mobile:" + resp.Mobile);
            }
            catch (Exception e)
            {
                error(
                    "获取验证码并不再使用这个手机号,mobile:" + mobile + ",uid:"
                    + uid + ",token:" + token + ",author_uid:" + author_uid + ",e:" +
                    e);
                resp.State = false;
            }
            return(resp);
        }