2011-02-16 33 views
2

我是使用Google Recaptcha Web服務在我的網站中的某些網頁中阻止垃圾信息的新功能,以及通過合併Javascript和PHP以響應我的網頁來使用AJAX的方法。如何訪問Recaptcha參數[recaptcha_challenge_field和recaptcha_response_field]?

我讀了所有在下面的鏈接與之相關的信息和我進行的步驟,一切是正確的。

Google Code recaptcha Documentation

我面臨的問題是在驗證過程中 [recaptcha_challenge_field和recaptcha_response_field]中使用的兩個領域

當我打電話的verify.php它給了我下面的錯誤recaptcha_check_answer功能: -

incorrect-captcha-sol

這意味着[recaptcha_challenge_field和recaptcha_response_field]爲空且未定義。

這兩個字段和變量應該有我在其過程中使用的驗證碼PHP庫輸入和應有的getter有他們,並傳遞提到的功能。

我搜索的PHP文件recaptchalib.php但我沒有找到它。

我應該添加隱藏式的新的輸入元素,並將其與recaptcha_challenge_field和recaptcha_response_field重命名爲存儲的ReCaptcha參數?

我不知道如何可以通過他們以正確的方式,因爲我離開他們的導遊說,但它並不能正常工作。我是否需要爲它們定義新的變量,以及如何將它們與實際的恢復參數相關聯。

我想請問誰執行驗證碼,並用它之前,告訴我該怎麼解決,我很欣賞你的幫助,在此先感謝您的回答

+1

請附上您的reCaptcha代碼。 – kjy112 2011-02-16 14:00:22

回答

1

http://code.google.com/apis/recaptcha/docs/php.html提供的客戶端代碼:

require_once('recaptchalib.php');<br /> 
$publickey = "your_public_key"; // you got this from the signup page<br /> 
echo recaptcha_get_html($publickey); 

擴展爲:

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=your_public_key"></script> 

<noscript> 
    <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br/> 
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> 
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> 
</noscript> 

現在,我得到了「無腳本」通過的版本僅包含n個內部線工作oscript標籤;而不是標籤本身,並完全刪除腳本標籤及其內容。缺點是需要您作爲批准過程的一部分進行手動複製粘貼。

腳本版本正在顯示,爽口,接受輸入,等,但recaptcha_challenge_field recaptcha_response_field CGI變量保持未設置,根據所述形式的目標PHP print_r($_POST);

所以我只剩下一半瞭解決上面提出的問題。