[РЕШЕНО] Java код для работы c антикапчей (antigate.com) возвращает ERROR_WRONG_USER_KEY (должно быть ERROR_ZERO_BALANCE - проверено на php) Подскажите в чем может быть причина ошибки? Правильно ли отправляется HTTP запрос вообще? Code: public String submit() throws Exception { HttpURLConnection connection = (HttpURLConnection) new URL("http://antigate.com/in.php").openConnection(); //Open the connection and prepare to POST connection.setDoOutput(true); connection.setDoInput(true); connection.setAllowUserInteraction(false); String boundary = "---------FGf4Fh3fdlKR148fdh"; byte[] content = readFile(new File("C:\\a.jpg")); //writeFile(new String (content, "8859_1")); String fileContent = new String(content, "8859_1"); String output = "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"method\"\r\n" + "\r\n" + "post\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"key\"\r\n" + "\r\n" + KEY + "\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"file\"; filename=\"capcha.jpg\"\r\n" + "Content-Type: image/pjpeg\r\n" + "\r\n" + fileContent + "\r\n" + "--" + boundary + "--"; //Set headers connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); connection.setRequestProperty("Content-Length", new Integer(output.length()).toString()); connection.setRequestProperty("Accept", "*/*"); connection.connect(); DataOutputStream dstream = new DataOutputStream(connection.getOutputStream()); //Send request dstream.writeBytes(output); dstream.close(); //Read response BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder buf = new StringBuilder(); String line; while ((line = r.readLine()) != null) { buf.append(line); } r.close(); connection.disconnect(); return buf.toString(); }
и так не помогает... может быть причина в кодировке отсылаемой строки ? если так , то какой вариант отсылать ? уже не знаю в чем причина - код вроде бы простой
РЕШЕНО: не хватало хеддеров ) код исправлен (но возможны ошибки с кодировкой String класса при отсылке запроса: файл капчи прочтен в одной кодировке, а запрос отправляется в кодировке по дефолту)