Ejemplo n.º 1
0
 public Status GetStatus()
 {
     HttpClient client = new HttpClient();
     if (Key == null)
     {
         throw new Exception("Captcha.GetStatus: Key is null");
     }
     if (CaptchaID == null)
     {
         throw new Exception("Captcha.GetStatus: CaptchaID is null");
     }
     string resp=client.DownloadString("http://antigate.com/res.php?key="+
                                       Key+"&action=get&id="+CaptchaID.ToString());
     if (resp.Contains("CAPCHA_NOT_READY"))
     {
         CaptchaStatus = Status.NotReady;
         return Status.NotReady;
     }
     if(resp.Substring(0,2)=="OK")
     {
         CaptchaText = resp.Substring(3);
         CaptchaStatus=Status.Success;
         return Status.Success;
     }
     CaptchaStatus=Status.Error;
     return Status.Error;
 }
Ejemplo n.º 2
0
 public Captcha(string Referer)
 {
     try
     {
     HttpClient client=new HttpClient();
     client.Referer=Referer;
     //Вытаскиваем токен каптчи
     string CaptchaData=client.DownloadString(Captcha.CaptchaAPIURL);
     CaptchaData=CaptchaData.Remove(0,CaptchaData.IndexOf(Captcha.ChallengeScanString)+
                                    ChallengeScanString.Length);
     CaptchaData=CaptchaData.Remove(0,CaptchaData.IndexOf(Captcha.ChallengeScanString2)+
                                    ChallengeScanString2.Length);
     CaptchaData=CaptchaData.Trim();
     if(CaptchaData[0]=='\'') CaptchaData=CaptchaData.Remove(0,1);
     CaptchaData=CaptchaData.Remove(CaptchaData.IndexOf('\''));
     /*
     client.Referer=Referer;
     string CaptchaImageURL=client.DownloadString(Captcha.CaptchaGAPIURL);
     CaptchaImageURL=CaptchaImageURL.Substring(CaptchaImageURL.IndexOf('\'')+1);
     CaptchaImageURL=CaptchaImageURL.Remove(CaptchaImageURL.IndexOf('\''));
     */
     string CaptchaImageURL=Captcha.CaptchaURLBase+CaptchaData;
     //Грузим картинку с каптчей
     client.Referer=null;
     Image=client.DownloadData(CaptchaImageURL);
     ChallengeID=CaptchaData;
     }catch (Exception e)
     {
         MainForm.SetStatus("Unable to load captcha: " + e.Message);
         throw e;
     }
 }