每當(dāng)我提交表單時(shí),即使存在有效令牌,我為無效令牌設(shè)置的錯(cuò)誤消息也會(huì)始終觸發(fā)。<script src="https://www.google.com/recaptcha/api.js?render=SITE_KEY"></script><script>grecaptcha.ready(function () { grecaptcha.execute('SITE_KEY', { action: 'contact' }).then(function (token) { var recaptchaResponse = document.getElementById('recaptchaResponse'); recaptchaResponse.value = token; });});表單中的隱藏字段: <input type="hidden" name="recaptcha_response" id="recaptchaResponse">我正在序列化整個(gè)表格:var form = $('#supportForm').serialize();如果我 console.log 可以看到令牌,那么那里沒問題。阿賈克斯: $.ajax({ url: 'validate.php', type: 'POST', dataType: 'json', data: form, //PHP$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';$recaptcha_secret = 'SECRET_KEY';$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $_POST['recaptcha_response']);$recaptcha = json_decode($recaptcha); if(!$recaptcha->success) { $message .= "'Robot verification passed, please try again"; }我不知道它是否失敗,因?yàn)樵谖业?google 帳戶中,我將域設(shè)置為 mydomain.com 但該表單實(shí)際上位于 mydomain.com/subdirectory設(shè)置驗(yàn)證碼時(shí)我無法添加子目錄。
Recaptcha 3 實(shí)施問題
ibeautiful
2021-12-24 16:08:55