Exemplo n.º 1
0
        public async Task <PhoneResult> ReleasePhone(string Phone)
        {
            var phoneResult = new PhoneResult();

            try
            {
                var rt  = $"http://cmyzm.5awo.com:8050/http.aspx?action=ReleaseMobile&uid=api_bashi&token=d2a9c4ac29bdae48&mobile={Phone}";
                var txt = await hc.GetStringAsync(rt);

                phoneResult.Success = true;
            }
            catch (Exception ex)
            {
                phoneResult.Success = false;
                phoneResult.Msg     = ex.Message;
            }
            return(phoneResult);
        }
Exemplo n.º 2
0
        public async Task <PhoneResult> GetPhoneAsync(string Phone = "")
        {
            var phoneResult = new PhoneResult();

            try
            {
                int cr = rand.Next(1, 4);
                var rt = $"http://cmyzm.5awo.com:8050/http.aspx?action=getMobilenum&pid=9116&uid=api_bashi&token=d2a9c4ac29bdae48&size=1&cr={cr}";
                if (string.IsNullOrWhiteSpace(Phone))
                {
                    rt = $"{rt}&mobile={Phone}";
                }
                var txt = await hc.GetStringAsync(rt);

                if (txt.Contains("|"))
                {
                    var phoneNumber = txt.Split('|')[0];
                    if (!phoneNumber.StartsWith("1"))
                    {
                        phoneResult.Success = false;
                        phoneResult.Msg     = $"获取手机号格式不正确:{txt}";
                    }
                    else
                    {
                        phoneResult.Success = true;
                    }
                    phoneResult.Data = phoneNumber;
                }
                else
                {
                    phoneResult.Success = false;
                    phoneResult.Msg     = $"获取手机号失败:{txt}";
                }
            }
            catch (Exception ex)
            {
                phoneResult.Success = false;
                phoneResult.Msg     = ex.Message;
            }
            return(phoneResult);
        }
Exemplo n.º 3
0
        public async Task <PhoneResult> GetSMSAsync(string Phone)
        {
            var phoneResult = new PhoneResult();

            try
            {
                var rt  = $"http://cmyzm.5awo.com:8050/http.aspx?action=getVcodeAndReleaseMobile&uid=api_bashi&token=d2a9c4ac29bdae48&pid=9116&mobile={Phone}";
                var txt = await hc.GetStringAsync(rt);

                if (txt.Contains("|"))
                {
                    Regex regex = new Regex(@"(?<!\d)\d{4,6}(?!\d)");

                    var matches = regex.Matches(rt);
                    if (!regex.IsMatch(txt))
                    {
                        phoneResult.Success = false;
                        phoneResult.Msg     = "验证码解析失败";
                    }
                    else
                    {
                        phoneResult.Success = true;
                        phoneResult.Data    = regex.Match(txt).Value;
                    }
                }
                else
                {
                    phoneResult.Success = false;
                    phoneResult.Msg     = "返回内容中没有找到|";
                }
            }
            catch (Exception ex)
            {
                phoneResult.Success = false;
                phoneResult.Msg     = ex.Message;
            }
            return(phoneResult);
        }