我需要在我的ZF應用程序的表單中插入ReCaptcha。我試圖遵循官方文檔,但ReCaptcha服務總是返回錯誤'錯誤 - 驗證碼'。 我正在使用的代碼:Zend框架和ReCaptcha
(格式)
// configure the captcha service
$privateKey = 'XXXXXXXXXXXXXXXXXXX';
$publicKey = 'YYYYYYYYYYYYYYYYYYYY';
$recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey);
// create the captcha control
$captcha = new Zend_Form_Element_Captcha('captcha',
array('captcha' => 'ReCaptcha',
'captchaOptions' => array(
'captcha' => 'ReCaptcha',
'service' => $recaptcha)));
$this->addElement($captcha);
(在控制器)
$recaptcha = new Zend_Service_ReCaptcha('YYYYYYYYYYYYY', 'XXXXXXXXXXXXXXX');
$result = $recaptcha->verify($this->_getParam('recaptcha_challenge_field'),
$this->_getParam('recaptcha_response_field'));
if (!$result->isValid()) {
//ReCaptcha validation error
}
任何幫助嗎?
你說得對!非常感謝!你救了我! :) – Stefano 2009-12-13 09:24:46