I have implemented reCaptcha in the application I am working on. Somehow I am getting a blank reCaptcha response.
It works fine with localhost, but I am having a problem in upper environments like DEV, TEST. User response is being verified on server side (servlet).
Anyone having idea or faced similar problem ? Let me know if you need more info.
String userresponse = (String) request.getAttribute("g-recaptcha-response");
URL url = null;
HttpURLConnection conn = null;
String line, outputString = "";
try {
url = new URL(https://www.google.com/recaptcha/api/siteverify?secret=privateKey&response=userresponse);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
while ((line = reader.readLine()) != null) {
outputString += line;
}
Log.debug("Google response is :- "+outputString);
} catch (IOException e) {
e.printStackTrace();
}