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;
}
}