-2
A
回答
1
您可以使用這樣的事情在你控制器驗證表單:
private boolean isRecaptchaValid(String recaptchaKey, String useRecaptcha) {
String recaptchaSecretKey = configuration.getString("recaptchaSecretKey");
WSRequest holder = ws.url("https://www.google.com/recaptcha/api/siteverify");
holder.setQueryParameter("secret", recaptchaSecretKey);
holder.setQueryParameter("response", recaptchaKey);
CompletionStage<JsonNode> jsonPromise = holder.post("").thenApply(WSResponse::asJson);
JsonNode googleResponse = null;
try{
googleResponse = jsonPromise.toCompletableFuture().get(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e){
e.printStackTrace();
} catch (ExecutionException e){
e.printStackTrace();
} catch (TimeoutException e){
e.printStackTrace();
}
if (googleResponse!= null && googleResponse.get("success") != null && googleResponse.get("success").asBoolean()) {
return true;
}
return false;
}
相關問題
- 1. 播放使用Java媒體框架
- 2. 使用Java 1.8播放框架1.2.7.x
- 3. 轉換播放框架Java Promise播放框架Scala Promise
- 4. 使用播放框架
- 5. 使用播放框架
- 6. Yii框架:reCaptcha
- 7. 播放框架NoClassDefFoundError
- 8. 播放框架CompilationException
- 9. 播放框架GUID
- 10. 播放框架1.2.4
- 11. AJAX播放框架
- 12. 播放框架掛
- 13. 播放框架db.play.JPA
- 14. Java的播放框架2.0.4 ebean查詢
- 15. 播放框架資產的Java驗證
- 16. 如何播放框架(Java)的
- 17. KML在播放框架中的Java API
- 18. 使用Ebean和播放框架
- 19. 使用與播放框架數據庫
- 20. 使用Neo4j-Anormcypher播放框架
- 21. 使用噴泉json播放框架
- 22. 使用MongoDB和Jongo播放框架
- 23. 播放框架:使用Apache安全WebSocket
- 24. 播放框架2.0:使用屬性值
- 25. 使用MongoDB的與播放2框架
- 26. jQuery無法使用播放框架
- 27. 如何使用WebSockets播放播放框架1.2.7
- 28. 使用videojs播放視頻在播放框架
- 29. 問題與播放easymail使用播放框架2.2
- 30. 播放框架2.1 - 使用java.util.properties在播放控制器