어드민 콘솔 접속 주소
https://www.google.com/recaptcha/admin
HTML 폼작성하기
<!-- recaptcha element -->
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<input type="hidden" id="recaptcha_response" name="recaptcha_response" value="" />
<div id="recaptcha_area"></div>
<script type="text/javascript">
var verify_value = "";
var onloadCallback = function() {
grecaptcha.render('recaptcha_area', {
'sitekey' : '{어드민 콘솔에서 발급받은 사이트키}',
'callback' : function(response) {
if (response != "") {
verify_value = response;
}
},
'theme' : 'light'
});
};
</script>
<!-- //recaptcha element -->
<script>
// 폼서브밋시
$("#recaptcha_response").val(verify_value);
</script>
FORM DATA 처리 (php)
<?php
// recaptcha 확인
include_once 'Snoopy.class.php';
$snoopy = new Snoopy;
$data = array(
"secret" => '어드민 콘솔에서 발급받은 시크릿키',
"response" => $recaptcha_response
);
$snoopy->submit('https://www.google.com/recaptcha/api/siteverify', $data);
$response = json_decode($snoopy->results);
if (!$response->success) {
// fail
exit;
} else {
// success
}