Answer the question
In order to leave comments, you need to log in
How to test reCAPTCHA v3 and make sure it works?
Google 's instructions say:
Automatically Bind Call to Button
The easiest way to use reCAPTCHA v3 on your page is to include the necessary JavaScript resource and add a few attributes to your html button.
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<button class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'>Submit</button>
<script src="https://www.google.com/recaptcha/api.js"></script>
<button>
<input type="submit" id="Anketa">
<input type="submit" id="Anketa" data-sitekey="mysitekey12345" data-callback='onSubmit' data-action='submit'>
, and added id="demo-form" to the form tag. Answer the question
In order to leave comments, you need to log in
Recaptcha of the third version works using neural networks, analyzes the behavior and other signs of the client on the site and issues the result of request processing in the form of a response
'success' => true,
'challenge_ts' => '2021-05-12T10:56:23Z',
'hostname' => 'site.ru',
'score' => 0.90000000000000002,
'action' => 'submit',
/*СОЗДАЕМ ФУНКЦИЮ КОТОРАЯ ДЕЛАЕТ ЗАПРОС НА GOOGLE СЕРВИС*/
function getCaptcha($SecretKey) {
$Response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".SECRET_KEY."&response={$SecretKey}");
$Return = json_decode($Response);
return $Return;
}
/*ПРОИЗВОДИМ ЗАПРОС НА GOOGLE СЕРВИС И ЗАПИСЫВАЕМ ОТВЕТ*/
$Return = getCaptcha($_POST['g-recaptcha-response']);
//var_dump($_POST['g-recaptcha-response']);
/*ВЫВОДИМ НА ЭКРАН ПОЛУЧЕННЫЙ ОТВЕТ*/
//var_dump($Return);
/*ЕСЛИ ЗАПРОС УДАЧНО ОТПРАВЛЕН И ЗНАЧЕНИЕ score БОЛЬШЕ 0,5 ВЫПОЛНЯЕМ КОД*/
if($Return->success == true && $Return->score > 0.5){
тут код по дальнейшим действиям с формой
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question