Daily Archives: May 5, 2012


Zend_Form Recaptcha doesn’t work with SSL 1

I was able to get a recaptcha working on my Zend Framwork application, but as soon as I added the “‘ssl’ => true” to my zend_form, the captcha disappeared. Here is the code used in zend_form:

//captcha
$this->addElement('captcha', 'captcha', array(
	'label' => 'Please Type:',
	'required' => true,
	'captcha' => array(
		'pubkey' => RECAPTCHA_PUBLIC_KEY,
		'privkey' => RECAPTCHA_PRIVATE_KEY,
		'captcha' => 'reCaptcha',
		'ssl'	=> true
	)
));

The reason ssl didn’t work with recaptcha is because the secure URL was out of date in my zend framework library. To update, open /Zend/Service/ReCaptcha.php and update the server constants at the top to

/**
 * URI to the regular API
 *
 * @var string
 */
const API_SERVER = 'http://www.google.com/recaptcha/api';
 
/**
 * URI to the secure API
 *
 * @var string
 */
const API_SECURE_SERVER = 'https://www.google.com/recaptcha/api';
 
/**
 * URI to the verify server
 *
 * @var string
 */
const VERIFY_SERVER = 'http://www.google.com/recaptcha/api/verify';