2
I’m having trouble deploying Google’s CAPTCHA.
On the form page I added the script and the div of captcha:
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<form action='../envio_formularios/sendEmail_faca_proposta.jsp' >
<input name='Nome_0' id='nome_0' type='text'>
<input name='Email_1' id='email_1' type='text'>
<div class="g-recaptcha" data-sitekey="coloquei minha key aqui"></div>
<input type="submit"> 
</form>
So far so good....
Problem is in the sendEmail, how do I validate the key that was returned by the script ?
Then I saw I had this code in PHP:
 $secretKey = "Put your secret key here";
    $ip = $_SERVER['REMOTE_ADDR'];
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
    $responseKeys = json_decode($response,true);
    if(intval($responseKeys["success"]) !== 1) {
      echo '<h2>You are spammer ! Get the @$%K out</h2>';
    } else {
      echo '<h2>Thanks for posting comment.</h2>';
    }
How could you convert this request to JSP ?