【发布时间】:2017-08-07 19:58:53
【问题描述】:
因此,我正在尝试在某些网站上实施 Google 全新的 Invisible reCaptcha。
我完全按照这些步骤操作,但它不断给我缺失输入响应错误。
HTML 代码:
<form id="subscribe-form" class="form-inline" action="phpScripts/subscribe/subscribeHandler.php" method="post">
<div class="input-group">
<input type="email" name="email" class="form-control" size="50" placeholder="Email Address" required>
<div class="input-group-btn">
<button class="g-recaptcha btn btn-danger" data-sitekey="6LfoNhkUAAAAAEcQFx8vGHZKHXsZ_q0j2KDnmU9M" data-callback="submitForm">Subscribe</button>
</div>
</div>
</form>
PHP 代码:
<?php
include 'databaseConnection.php';
if($_POST){
$secret = "MY SECRET KEY";
$captcha= $_POST['g-recaptcha-response'];
$ip = $_SERVER['REMOTE_ADDR'];
$url= file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip=$ip");
print_r($url);
$decodedResponse = json_decode($url, TRUE);
if($decodedResponse['success'] == 1){//code here}
所以,我认为我的 $captcha 变量无法从 g-recaptcha-response 的 POST 中“捕获”任何内容。但是,为什么,这正是 Google 所说的,与旧的 reCaptcha v2 完全一样。
另外,我也加入了<script src='https://www.google.com/recaptcha/api.js'></script>
【问题讨论】:
标签: php html post recaptcha invisible