我试图插入google recaptcha invisble。在这种模式下,我看到了recaptcha invisble。 这是正常的吗? 在这种情况下,我会知道google recaptcha隐形脚本是否正确?也许我忘记了一个元素?
谢谢
我有头等舱 MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA .... ==普通v2 recaptcha。这个元素很完美 MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE ...... =无形回收
下面,这个元素在我的表单中写下代码。
class GoogleRecaptchaDisplay {
public function execute() {
$output = '';
if (!empty(MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_PUBLIC_KEY) && MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_STATUS == 'True') {
$output .= '<div class="col-md-12 g-recaptcha" data-sitekey="' . MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_PUBLIC_KEY . '"></div>';
} elseif (!empty(MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_PUBLIC_KEY) && MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_STATUS == 'True') {
$output .= '<div class="col-md-12 g-recaptcha" data-sitekey="' . MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_PUBLIC_KEY . '"></div>';
}
return $output;
}
}
在我的流程中,此元素为验证
class GoogleRecaptchaProcess {
/*
* Google recaptcha
* @return $error, false if it's ok, true, if there is an error
*/
public function execute() {
if (!empty(MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_PRIVATE_KEY) && MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_STATUS == 'True') {
$secret = MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_PRIVATE_KEY;
$response = $_POST["g-recaptcha-response"];
$verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");
$captcha_success = json_decode($verify);
$error = 'false';
if ($captcha_success->success === true) {
$error = 'false';
} else {
$error = 'true';
}
} elseif (!empty(MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_PRIVATE_KEY) && MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_STATUS == 'True') {
$secret = MODULES_HEADER_TAGS_GOOGLE_RECAPTCHA_INVISIBLE_PRIVATE_KEY;
$response = $_POST["g-recaptcha-response"];
$verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");
$captcha_success = json_decode($verify);
$error = 'false';
if ($captcha_success->success === true) {
$error = 'false';
} else {
$error = 'true';
}
}
return $error;
}
}