【发布时间】:2017-11-23 06:59:43
【问题描述】:
请帮助我使用这个 recaptcha v2。 我不知道是什么问题,但这是我的代码
if (isset($_POST['submit']))
{
if(isset($_POST['g-recaptcha-response'])){
//your site secret key
$secret = 'secrete key';
//get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
if($responseData->success){
//code here
}
else{
echo "<script>alert('Please click reCAPTCHA');</script>";
}
}
我在 localhost 中使用此代码我没有任何问题。我已经在 google recaptcha 中输入了我的域,我认为唯一的问题是代码。
【问题讨论】:
-
您的预期和实际发生了什么?