我在我正在处理的应用程序中实现了reCaptcha。不知怎的,我得到了一个空白的reCaptcha响应。
它适用于localhost,但我在DEV,TEST等上层环境中遇到问题。正在服务器端(servlet)验证用户响应。
任何有想法或遇到类似问题的人?如果您需要更多信息,请告诉我。
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();
}