Показать сообщение отдельно

  #11  
Старый 16.10.2009, 09:57
Пуховой
Banned
Регистрация: 25.11.2007
Сообщений: 62
С нами: 9715564

Репутация: 89
По умолчанию

bmp12, вот еще, кстати, попробуйте функцию (переписывал под себя, чтобы капчу на диск не сохранять)

Код:
function recognize (itype: string; key: string; image : tmemorystream) : string;
var
  ftype, s, id: string;
  i: integer;
  http: tidhttp;
  multi: tidmultipartformdatastream;
begin
  if strpos (pchar (itype), 'jpg') <> nil then ftype := 'image/pjpeg';
  if strpos (pchar (itype), 'gif') <> nil then ftype := 'image/gif';
  if strpos (pchar (itype), 'png') <> nil then ftype := 'image/png';
  multi := Tidmultipartformdatastream.Create;
  multi.AddFormField ('method', 'post');
  multi.AddFormField ('key', key);
  multi.AddObject ('file', ftype, image, 'captcha.' + itype);
  http := tidhttp.Create;
  s := http.Post ('http://antigate.com/in.php', multi);
  http.Free; multi.Free;
  id := '';
  if strpos (Pchar (s), 'ERROR_') <> nil then begin result := s; exit; end;
  if strpos (Pchar (s), 'OK|') <> nil then id := AnsiReplaceStr (s, 'OK|', '');
  if id = '' then result := 'ERROR: bad captcha id';
  for i := 1 to 20 do
  begin
    sleep (5000);
    http := tidhttp.Create;
    s := http.Get ('http://antigate.com/res.php?key=' + key + '&action=get&id=' + id);
    http.Free;
    if strpos (Pchar (s), 'ERROR_') <> nil then begin result := s; exit; end;
    if strpos (Pchar (s), 'OK|') <> nil then
    begin
      result := AnsiReplaceStr (s, 'OK|', '');
      exit;
    end;
  end;
  result := 'ERROR_TIMEOUT';
end;
Обращение: recognize ('jpg', ackey, image) - тип картинки / ас ключ / картинка в tmemorystream
 
Ответить с цитированием