Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Service_ReCaptcha Class Reference

Public Member Functions

 __construct ($publicKey=null, $privateKey=null, $params=null, $options=null, $ip=null)
 Class constructor.
 
 __toString ()
 Serialize as string.
 
 setIp ($ip)
 Set the ip property.
 
 getIp ()
 Get the ip property.
 
 setParam ($key, $value)
 Set a single parameter.
 
 setParams ($params)
 Set parameters.
 
 getParams ()
 Get the parameter array.
 
 getParam ($key)
 Get a single parameter.
 
 setOption ($key, $value)
 Set a single option.
 
 setOptions ($options)
 Set options.
 
 getOptions ()
 Get the options array.
 
 getOption ($key)
 Get a single option.
 
 getPublicKey ()
 Get the public key.
 
 setPublicKey ($publicKey)
 Set the public key.
 
 getPrivateKey ()
 Get the private key.
 
 setPrivateKey ($privateKey)
 Set the private key.
 
 getHtml ($name=null)
 Get the HTML code for the captcha.
 
 verify ($challengeField, $responseField)
 Verify the user input.
 

Public Attributes

const API_SERVER = 'http://www.google.com/recaptcha/api'
 
const API_SECURE_SERVER = 'https://www.google.com/recaptcha/api'
 
const VERIFY_SERVER = 'http://www.google.com/recaptcha/api/verify'
 

Protected Member Functions

 _post ($challengeField, $responseField)
 Post a solution to the verify server.
 

Protected Attributes

 $_publicKey = null
 
 $_privateKey = null
 
 $_ip = null
 
 $_params
 
 $_options
 
 $_response = null
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Service_Abstract
static setHttpClient (Zend_Http_Client $httpClient)
 Sets the HTTP client object to use for retrieving the feeds.
 
static getHttpClient ()
 Gets the HTTP client object.
 
- Static Protected Attributes inherited from Zend_Service_Abstract
static $_httpClient = null
 

Constructor & Destructor Documentation

__construct (   $publicKey = null,
  $privateKey = null,
  $params = null,
  $options = null,
  $ip = null 
)

Class constructor.

Parameters
string$publicKey
string$privateKey
array$params
array$options
string$ip
array | Zend_Config$params

Member Function Documentation

__toString ( )

Serialize as string.

When the instance is used as a string it will display the recaptcha. Since we can't throw exceptions within this method we will trigger a user warning instead.

Returns
string
_post (   $challengeField,
  $responseField 
)
protected

Post a solution to the verify server.

Parameters
string$challengeField
string$responseField
Returns
Zend_Http_Response
Exceptions
Zend_Service_ReCaptcha_Exception
See Also
Zend_Service_ReCaptcha_Exception
Zend_Service_ReCaptcha_Exception
getHtml (   $name = null)

Get the HTML code for the captcha.

This method uses the public key to fetch a recaptcha form.

Parameters
null | string$nameBase name for recaptcha form elements
Returns
string
Exceptions
Zend_Service_ReCaptcha_Exception
See Also
Zend_Service_ReCaptcha_Exception
getIp ( )

Get the ip property.

Returns
string
getOption (   $key)

Get a single option.

Parameters
string$key
Returns
mixed
getOptions ( )

Get the options array.

Returns
array
getParam (   $key)

Get a single parameter.

Parameters
string$key
Returns
mixed
getParams ( )

Get the parameter array.

Returns
array
getPrivateKey ( )

Get the private key.

Returns
string
getPublicKey ( )

Get the public key.

Returns
string
setIp (   $ip)

Set the ip property.

Parameters
string$ip
Returns
Zend_Service_ReCaptcha
setOption (   $key,
  $value 
)

Set a single option.

Parameters
string$key
string$value
Returns
Zend_Service_ReCaptcha
setOptions (   $options)

Set options.

Parameters
array | Zend_Config$options
Returns
Zend_Service_ReCaptcha
Exceptions
Zend_Service_ReCaptcha_Exception
See Also
Zend_Service_ReCaptcha_Exception
setParam (   $key,
  $value 
)

Set a single parameter.

Parameters
string$key
string$value
Returns
Zend_Service_ReCaptcha
setParams (   $params)

Set parameters.

Parameters
array | Zend_Config$params
Returns
Zend_Service_ReCaptcha
Exceptions
Zend_Service_ReCaptcha_Exception
See Also
Zend_Service_ReCaptcha_Exception
setPrivateKey (   $privateKey)

Set the private key.

Parameters
string$privateKey
Returns
Zend_Service_ReCaptcha
setPublicKey (   $publicKey)

Set the public key.

Parameters
string$publicKey
Returns
Zend_Service_ReCaptcha
verify (   $challengeField,
  $responseField 
)

Verify the user input.

This method calls up the post method and returns a Zend_Service_ReCaptcha_Response object.

Parameters
string$challengeField
string$responseField
Returns
Zend_Service_ReCaptcha_Response

Member Data Documentation

$_ip = null
protected
$_options
protected
Initial value:
= array(
'theme' => 'red',
'lang' => 'en',
'custom_translations' => array(),
)
$_params
protected
Initial value:
= array(
'ssl' => false,
'error' => null,
'xhtml' => false
)
$_privateKey = null
protected
$_publicKey = null
protected
$_response = null
protected
const API_SECURE_SERVER = 'https://www.google.com/recaptcha/api'
const API_SERVER = 'http://www.google.com/recaptcha/api'
const VERIFY_SERVER = 'http://www.google.com/recaptcha/api/verify'