Instantiate a Zend_Service_ReCaptcha object, passing it
your public and private keys:
Example 811. Creating an instance of the reCAPTCHA service
<?php
$recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey);
To render the reCAPTCHA, simply call the getHTML()
method:
When the form is submitted, you should receive two fields,
'recaptcha_challenge_field' and 'recaptcha_response_field'. Pass
these to the reCAPTCHA object's verify() method:
Example 813. Verifying the form fields
<?php
$result = $recaptcha->verify(
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']
);
Once you have the result, test against it to see if it is valid. The
result is a Zend_Service_ReCaptcha_Response object,
which provides an isValid() method.
It is even simpler to use the reCAPTCHA
Zend_Captcha adapter, or to use that adapter as a
backend for the CAPTCHA form
element. In each case, the details of rendering and
validating the reCAPTCHA are automated for you.




