"; print_r($response_data); echo ""; return $response_data; } } ///////////////////////////// OR ///////////////////////////// /* class Captcha { public function getCaptcha($SecretKey) { $Resposta = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . RECAPTCHA_SECRET_KEY . "&response={$SecretKey}"); $Retorno = json_decode($Resposta); return $Retorno; } } */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { //echo "
"; print_r($_REQUEST); echo ""; $ObjCaptcha = new Captcha(); $Retorno = $ObjCaptcha->getCaptcha($_POST['g-recaptcha-response']); //echo "
"; print_r($Retorno); echo ""; if ($Retorno->success) { echo '
CAPTCHA was completed successfully!
'; mail($to, $subject, $msgBody, $headers); } else { $error_codes = 'error-codes'; if (isset($Retorno->$error_codes) && in_array("timeout-or-duplicate", $Retorno->$error_codes)) { $captcha_msg = "The verification expired due to timeout, please try again."; } else { $captcha_msg = "Check to make sure your keys match the registered domain and are in the correct locations.reCAPTCHA error: ' . $captcha_msg . '
'; } } ?>