2012-01-14 14 views
3

ReCaptchaをインストールして私の公開鍵と秘密鍵を設定しました。それが良いか間違っていても何でも答えを入力するまでは問題ありません。発生したエラーで応答します。ここでReCaptchaは常にエラーを返さずにエラーを返す

は私のコードです:

require_once('recaptchalib.php'); 
$resp = recaptcha_check_answer ($config->privkey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); 

if (!$resp->is_valid) { 
    echo $resp->error; 
} 

答えて

5

は溶液で

define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net"); 
define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net"); 
define("RECAPTCHA_VERIFY_SERVER", gethostbyname('api-verify.recaptcha.net')); 

へ:

define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api"); 
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api"); 
define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); 

これはおそらく古い

http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest

みんなありがとうを:PHPライブラリ、あなたはまた、最新のライブラリをダウンロードすることが良くなりますように。

+0

はい。バージョン1.11(確かに)は新しいURLを持っています。 –

+0

確認** recaptcha_check_answer(...)**は常に** http **で行われ、** https **では決して行われません。公開鍵が暗号化されて送信されたとしても、秘密鍵は平文で送信されます。彼らの奇妙な選択。 –

0

あなたが設定ファイルでフォームファイル&秘密鍵で公開鍵を持っている必要があります:

<html> 
<body> <!-- the body tag is required or the CAPTCHA may not show on some browsers --> 
    <!-- your HTML content --> 

    <form method="post" action="verify.php"> 
    <?php 
     require_once('recaptchalib.php'); 
     $publickey = "your_public_key"; // you got this from the signup page 
     echo recaptcha_get_html($publickey); 
    ?> 
    <input type="submit" /> 
    </form> 

    <!-- more of your HTML content --> 
</body> 
</html> 

これは、フォームの要求が行くあなたのファイルです。

<?php 
    require_once('recaptchalib.php'); 
    $privatekey = "your_private_key"; 
    $resp = recaptcha_check_answer ($privatekey, 
          $_SERVER["REMOTE_ADDR"], 
          $_POST["recaptcha_challenge_field"], 
          $_POST["recaptcha_response_field"]); 

    if (!$resp->is_valid) { 
    // What happens when the CAPTCHA was entered incorrectly 
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . 
    "(reCAPTCHA said: " . $resp->error . ")"); 
    } else { 
    // Your code here to handle a successful verification 
    } 
    ?> 

さらにお問い合わせ先:http://code.google.com/apis/recaptcha/docs/php.htmlあなたのrechaptchalib.php変更で

:誰かが同様の問題を持っている場合、私はここで...

を検索する日後に答えを見つけた

+0

設定ファイルやフォームファイルに公開鍵を持っていても問題ありません...あなたの答えは残念なことに助けになりません。 – Cyclone

関連する問題