php - Recaptcha no longer working after update to checkbox style version -


i using new version of recaptcha - 1 has check box instead of text field.

however doesnt work. although new recaptcha appears, error page each time check box.

i've looked through documentation , doesnt mention thing different old 1 setting up.

ive downloaded latest recaptchalib.php, added <script src='https://www.google.com/recaptcha/api.js'></script> in header , have set server side script such:

  require_once('recaptchalib.php');   $privatekey = "myprivatekey";   $resp = recaptcha_check_answer ($privatekey,                                 $_server["remote_addr"],                                 $_post["recaptcha_challenge_field"],                                 $_post["recaptcha_response_field"]);    if (!$resp->is_valid) {     //captcha entered incorrectly     header( "location: $error_page" );      die ("the recaptcha wasn't entered correctly. go , try again." .          "(recaptcha said: " . $resp->error . ")");   } else {     //successful verification 

my client side seems fine, simply:

<div class="g-recaptcha" data-sitekey="mypublickey"></div> 

of course, i've double checked both keys , paths correct.

is there new library meant use or different way of processing new check box type recaptcha? doing wrong?

are absolutely sure included recaptchalib.php using new api ? can double check ?

i'm asking because see latest version of recaptcha-php 1.11, released in 2010 , don't see updates in vcs either.

that library using old api:

$response = _recaptcha_http_post (recaptcha_verify_server, "/recaptcha/api/verify",     array (          'privatekey' => $privkey,          'remoteip' => $remoteip,          'challenge' => $challenge,          'response' => $response          ) + $extra_params     ); 

the new api should called like:

https://www.google.com/recaptcha/api/siteverify?secret=your_secret&response=response_string&remoteip=user_ip_address 

a simple implementation login form, like:

<form role="form" method="post" action="/login_check.php">    <input type="text" class="" id="username" placeholder="enter username">    <input type="password" class="" id="password">     <div class="g-recaptcha" data-sitekey="[your site key]"></div> </form>  <script src='https://www.google.com/recaptcha/api.js'></script> 

in login_check.php:

<?php  // yours https://www.google.com/recaptcha/intro/index.html $api_secret     = 'your api secret'; $api_endpoint   = 'https://www.google.com/recaptcha/api/siteverify';  if ((strtoupper($_server["request_method"])) === "post") {      if (empty($_post['g-recaptcha-response'])) {         // user did not complete recaptcha         header("location: index.php");         exit;     }      $api_url    = sprintf('%s?secret=%s&response=%s&remoteip=%s', $api_endpoint, $api_secret, $_post['g-recaptcha-response'], $_server['remote_addr']);     $response   = json_decode(apiverify($api_url), true);      // recaptcha not correct.     if (false === $response['success']) {         // user not human.         header("location: index.php");         exit;     }      // recaptcha correct, can go ahead , check login credentials ...      echo "welcome !"; }  function apiverify($url) {     $curl = curl_init();      curl_setopt($curl, curlopt_url, $url);     curl_setopt($curl, curlopt_returntransfer, 1);     curl_setopt($curl, curlopt_timeout, 10);     curl_setopt($curl, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.2.16) gecko/20110319 firefox/3.6.16");      $data = curl_exec($curl);      curl_close($curl);      return $data; } 

you (and should) extend example in order show feedback user, perform validation, etc, think should suffice in order started.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -