string apikey = "CJ9MZ0JCTALRZ9HXIIXY5AMB6950MEJP";
string response = String.Empty;
string sms = String.Empty;
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getNumbersStatus", apikey), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000, "", "", false, 5, null, "", false);
CountNumber cn = new JavaScriptSerializer().Deserialize<CountNumber>(response);
if(cn.ya_0 <= 0)
{
//project.SendInfoToLog("номеров нет, прекращаем работу", true);
//return null;
throw new Exception("номеров нет, прекращаем работу");
}
else
{
project.SendInfoToLog(String.Format("количество свободных номеров{0}, продолжаем регистрацию", cn.ya_0), true);
}
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getNumber&service=ya_0&country=ru", apikey), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
if(response.ToLower().Contains("no key"))
throw new Exception("Неверный apikey");
if(response.ToLower().Contains("no action"))
throw new Exception("Не указана API-функция");
if(response.ToLower().Contains("bad key"))
throw new Exception("Неверный apikey");
if(response.ToLower().Contains("bad action"))
throw new Exception("Неверная API-функция");
if(response.ToLower().Contains("error sql"))
throw new Exception("Ошибка SQL-сервера");
if(response.ToLower().Contains("bad service"))
throw new Exception("Неверный сервис");
if(response.ToLower().Contains("bad country"))
throw new Exception("Неверная страна");
if(response.ToLower().Contains("no means"))
throw new Exception("Недостаточно средств на счету");
if(response.ToLower().Contains("no number"))
throw new Exception("Нет номеров с заданными параметрами");
string[] getNumber = response.Split(':');
string id = getNumber[1];
string number = getNumber[2];
project.SendInfoToLog(id + "|" + number);
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=setStatus&id={1}&status=1", apikey, id), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
project.SendInfoToLog(response);
for(int i = 0; i < 10; i++)
{
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getStatus&id={1}", apikey, id), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
project.SendInfoToLog(response);
}
return response;
string response = String.Empty;
string sms = String.Empty;
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getNumbersStatus", apikey), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000, "", "", false, 5, null, "", false);
CountNumber cn = new JavaScriptSerializer().Deserialize<CountNumber>(response);
if(cn.ya_0 <= 0)
{
//project.SendInfoToLog("номеров нет, прекращаем работу", true);
//return null;
throw new Exception("номеров нет, прекращаем работу");
}
else
{
project.SendInfoToLog(String.Format("количество свободных номеров{0}, продолжаем регистрацию", cn.ya_0), true);
}
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getNumber&service=ya_0&country=ru", apikey), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
if(response.ToLower().Contains("no key"))
throw new Exception("Неверный apikey");
if(response.ToLower().Contains("no action"))
throw new Exception("Не указана API-функция");
if(response.ToLower().Contains("bad key"))
throw new Exception("Неверный apikey");
if(response.ToLower().Contains("bad action"))
throw new Exception("Неверная API-функция");
if(response.ToLower().Contains("error sql"))
throw new Exception("Ошибка SQL-сервера");
if(response.ToLower().Contains("bad service"))
throw new Exception("Неверный сервис");
if(response.ToLower().Contains("bad country"))
throw new Exception("Неверная страна");
if(response.ToLower().Contains("no means"))
throw new Exception("Недостаточно средств на счету");
if(response.ToLower().Contains("no number"))
throw new Exception("Нет номеров с заданными параметрами");
string[] getNumber = response.Split(':');
string id = getNumber[1];
string number = getNumber[2];
project.SendInfoToLog(id + "|" + number);
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=setStatus&id={1}&status=1", apikey, id), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
project.SendInfoToLog(response);
for(int i = 0; i < 10; i++)
{
response = ZennoPoster.HttpGet(String.Format("http://api.getsms.online/stubs/handler_api.php?api_key={0}&action=getStatus&id={1}", apikey, id), "", "utf-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 10000);
project.SendInfoToLog(response);
}
return response;