Example #1
0
        public override string GetNumber()
        {
            try
            {
                var answer =
                    GetResponse("http://simsms.org/priemnik.php?" +
                                $"metod=get_number&country=ru&service={ViberKey}&id=1&apikey={ApiKey}");
                if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "1")
                {
                    return(null);
                }

                var tzid   = new Regex("(?<=id\":).*?(?=,)").Match(answer).Value;
                var number = new Regex("(?<=number\":\").*?(?=\")").Match(answer).Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SimSms)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SimSms)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
        public override string GetNumber()
        {
            try
            {
                var url    = "http://onlinesim.ru/api/getNum.php?" + $"service={ViberKey}&apikey={ApiKey}";
                var answer = GetResponse(url);

                if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "1")
                {
                    return(null);
                }
                var tzid = Regex.Match(answer, "(?<=\"tzid\":).*?(?=})").Value;

                url    = "http://onlinesim.ru/api/getState.php?" + $"tzid={tzid}&apikey={ApiKey}";
                answer = GetResponse(url);
                var sw = Stopwatch.StartNew();
                while (Regex.Match(answer, "(?<=\"response\":\").*?(?=\")").Value != "1" &&
                       (sw.ElapsedMilliseconds < 60000))
                {
                    if (answer.Contains("TZ_INPOOL"))
                    {
                        Thread.Sleep(10500);
                        answer = GetResponse(url);
                        continue;
                    }
                    if (!answer.Contains("TZ_NUM_WAIT"))
                    {
                        return(null);
                    }
                    var number = new Regex("(?<=number\":\").*?(?=\")").Match(answer).Value;
                    if (string.IsNullOrWhiteSpace(number))
                    {
                        throw new Exception($"{nameof(OnlineSim)} {nameof(GetNumber)} Переменная {number} пуста");
                    }
                    if (TzidNumbers.ContainsKey(number))
                    {
                        TzidNumbers[number] = tzid;
                    }
                    else
                    {
                        TzidNumbers.Add(number, tzid);
                    }
                    return(number);
                }
                sw.Stop();
                return(null);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(OnlineSim)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
Example #3
0
        public override string GetNumber()
        {
            try
            {
                string url = "http://sms-activate.ru/stubs/handler_api.php?" +
                             $"api_key={ApiKey}&action=getNumber&service={ViberKey}";
                string answer = GetResponse(url);
                switch (answer)
                {
                case "NO_NUMBERS":
                    return(null);

                case "NO_BALANCE":
                    return(null);

                case "BAD_ACTION":
                    return(null);

                case "BAD_SERVICE":
                    return(null);

                case "BAD_KEY":
                    return(null);

                case "ERROR_SQL":
                    return(null);
                }
                var    tzid   = Regex.Match(answer, "(?<=ACCESS_NUMBER:).*?(?=:)").Value;
                string number = Regex.Match(answer, "(?<=\\d:).*").Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SmsActivate)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsActivate)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
Example #4
0
        public override string GetNumber()
        {
            try
            {
                string tzid;
                string url = "http://smslike.ru/index.php?mode=api" +
                             $"&apikey={ApiKey}&action=regnum&lc=0&s={ViberKey}";
                var answer = GetResponse(url);
                var check  = Regex.IsMatch(answer, "OK");
                switch (answer)
                {
                case "BEFORE_REQUEST_NEW_REPLY_COMPLE_REQUESTED_BEFORE":
                    return(null);

                case "ACTIVE_REQUESTS_LIMIT":
                    return(null);

                case "WARNING_LOW_BALANCE":
                    return(null);

                case "WARNING_NO_NUMS":
                    return(null);

                default:
                    if (check)
                    {
                        tzid = answer.Split(':')[1].Trim();
                    }
                    else
                    {
                        return(null);
                    }
                    break;
                }

                url    = "http://smslike.ru/index.php?mode=api" + $"&apikey={ApiKey}&action=getstate&tz={tzid}";
                answer = GetResponse(url);
                var sw = Stopwatch.StartNew();
                while (!answer.Contains("TZ_NUM_PREPARE") && (sw.ElapsedMilliseconds < 60000))
                {
                    if (answer != "TZ_NUM_WAIT_NUMBER")
                    {
                        return(null);
                    }
                    Thread.Sleep(10500);
                    answer = GetResponse(url);
                }
                sw.Stop();
                var number = Regex.Match(answer, "(?<=TZ_NUM_PREPARE:).*").Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SmsLike)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsLike)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }