No Captcha ReCaptcha with Perl Formmail Script

183 views
Skip to first unread message

pjo...@gmail.com

unread,
Dec 23, 2014, 10:59:05 AM12/23/14
to reca...@googlegroups.com
Hi everyone, I'm trying to get the new No Captcha ReCaptcha to work with my Formmail Perl CGI script.  The widget renders but I'm having trouble verifying the user's response.  If anyone can point me to a thorough tutorial that would be great.

David Boothe

unread,
Dec 31, 2014, 3:03:32 AM12/31/14
to reca...@googlegroups.com
I am workign with the same exact issue.  I cannot for the life of me get the new noCaptcha to validtae in the Perl script. The old reCaptcha works fine but I really want to move to the new one if at all possible.

David Boothe

unread,
Dec 31, 2014, 5:53:45 AM12/31/14
to reca...@googlegroups.com
I have this working now.  The function tests for a valid captcha and returns one of three conditions.

1 - successful connect to google - captcha data invalid
2 - successful connect to google - captcha data valid
3 - connect to goggle failed

sub check_captcha {
use LWP::UserAgent;
 $capurl = 'https://www.google.com/recaptcha/api/siteverify';
 $capres = $Form{'g-recaptcha-response'};
 $capsec = PUT_YOUR_SECRET_KEY_HERE';
 my $ua = LWP::UserAgent->new();
 my $response = $ua->post($capurl, ['response' => $capres, 'secret' => $capsec]);
 if ($response->is_success) {
  $capcnt = $response->decoded_content;
  $capnum = index($capcnt, 'true');
  if ($capnum == -1) {
   CONDITION_1_CODE_GOES_HERE
  } else {
   CONDITION_2_CODE_GOES_HERE
   return;
  }
 } else {
  CONDITION_2_CODE_GOES_HERE
  return;
 }
}

David Boothe

unread,
Dec 31, 2014, 9:40:03 AM12/31/14
to reca...@googlegroups.com
THE LAST CONDITION SHOULD BE 3 NOT 2

Reply all
Reply to author
Forward
0 new messages