1
验证它的时候总是返回false后,我得到令牌g-recaptcha-response
的响应,我与验证码验证它是这样的:验证码与谷歌
@Service
public class RecaptchaService {
private static class RecaptchaResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("error-codes")
private Collection<String> errorCodes;
}
@Value("${recaptcha.url}")
private String recaptchaUrl;
@Value("${recaptcha.secret-key}")
private String recaptchaSecretKey;
public boolean isResponseValid(String response) {
RestTemplate restTemplate = new RestTemplate();
Map<String, String> params = new HashMap<String, String>();
params.put("secret", recaptchaSecretKey);
params.put("response", response);
RecaptchaResponse recaptchaResponse = restTemplate.postForEntity(recaptchaUrl, params, RecaptchaResponse.class).getBody();
return recaptchaResponse.success;
}
}
但我总是得到false
为recaptchaResponse.success
和[missing-input-response, missing-input-secret]
为error-codes