我有来自godaddy和scalahosting的两个共享主机帐户,我在主机帐户上测试这个google recaptcha代码这个代码在godaddy上工作但不在scalahosting中,输出结果将是(在此代码中)“
< h2>你是垃圾邮件发送者!“那么这是什么问题?
这是网络托管问题吗?还是?
<html>
<head>
<title>Google recapcha demo - Codeforgeek</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<h1>Google reCAPTHA Demo</h1>
<form id="comment_form" action="form.php" method="post">
<input type="email" placeholder="Type your email" size="40"><br><br>
<textarea name="comment" rows="8" cols="39"></textarea><br><br>
<input type="submit" name="submit" value="Post comment"><br><br>
<div class="g-recaptcha" data-sitekey="6LftgAUTAAAAAAQkns-ihN6BIbp4Tje5_OF_TSv5"></div>
</form>
</body>
</html>
<?php
$email;$comment;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}if(isset($_POST['comment'])){
$email=$_POST['comment'];
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$secretKey = "6LftgAUTAAAAAIcMb0tbYDYBN9mi_ZyIydMe2Zug";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>You are spammer !t</h2>';
} else {
echo '<h2>Thanks for posting comment.</h2>';
}
?>
答案 0 :(得分:0)
每个域都需要一个单独的密钥,并且该域名需要添加到重新访问的域名中。