I am currently using the reCaptcha library available here to run reCaptcha on my web site which uses LAMP version 2.2.22, and PHP version 5.4.39-0+deb7u2, on Debian 6.5. My PHP code is as follows.
// Recaptcha check
$secret = "SomeAlphaNumericGibberish";
$response = null;
$reCaptcha = new ReCaptcha($secret);
if ($reCaptcha ==NULL){
echo "Null pointer " . "<br>";
} else{
echo "Valid pointer " . "<br>";
}
if ($_POST["g-recaptcha-response"]) {
echo "Remote IP: ". $_SERVER["REMOTE_ADDR"] . "<br>";
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
if ($response != null && $response->success) {
echo "Welcome " . $_POST["username"] . "!" . "<br>";
} else if ($response == null) {echo "Null pointer " . "<br>";}
else {
echo "Bad response" . "<br>";
foreach ($response->getErrorCodes() as $code) {
echo $code . "<br>";
}
echo "End of error codes" . "<br>";
}
The output is as follows
Valid pointer
Remote IP: 192.168.1.4
Bad response
However, I don't get any output after that. I ran
sudo cat /var/log/apache2/error.log
and got
PHP Fatal error: Call to undefined method ReCaptchaResponse::getErrorCodes()
I was unable to find any discussions about this error message.