Service/ReCaptcha.php
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service
- Subpackage
- ReCaptcha
\Zend_Service_ReCaptcha
- Parent(s)
- \Zend_Service_Abstract
- Children
- \Zend_Service_ReCaptcha_MailHide
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id: ReCaptcha.php 25153 2012-11-28 11:56:23Z cogo $
Constants
Properties


\Zend_Http_Client $_httpClient = null
null
Details- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient


array $_options = array('theme' => 'red', 'lang' => 'en')
See the different options on http://recaptcha.net/apidocs/captcha/client.html
array('theme' => 'red', 'lang' => 'en')
Details- Type
- array


array $_params = array('ssl' => false, 'error' => null, 'xhtml' => false)
array('ssl' => false, 'error' => null, 'xhtml' => false)
Details- Type
- array


string $_privateKey = null
null
Details- Type
- string


string $_publicKey = null
null
Details- Type
- string
Methods


__construct(string $publicKey = null, string $privateKey = null, array | array | \Zend_Config $params = null, array $options = null, string $ip = null) : void
Class constructor
Name | Type | Description |
---|---|---|
$publicKey | string | |
$privateKey | string | |
$params | array | array | \Zend_Config | |
$options | array | |
$ip | string |


__toString() : string
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.
Type | Description |
---|---|
string |


_post(string $challengeField, string $responseField) : \Zend_Http_Response
Post a solution to the verify server
Name | Type | Description |
---|---|---|
$challengeField | string | |
$responseField | string |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Service_ReCaptcha_Exception |


getHtml(null | string $name = null) : string
Get the HTML code for the captcha
This method uses the public key to fetch a recaptcha form.
Name | Type | Description |
---|---|---|
$name | null | string | Base name for recaptcha form elements |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Service_ReCaptcha_Exception |


getHttpClient() : \Zend_Http_Client
Gets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()Type | Description |
---|---|
\Zend_Http_Client |


getOption(string $key) : mixed
Get a single option
Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
mixed |


getParam(string $key) : mixed
Get a single parameter
Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
mixed |


setHttpClient(\Zend_Http_Client $httpClient) : void
Sets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
Name | Type | Description |
---|---|---|
$httpClient | \Zend_Http_Client |


setIp(string $ip) : \Zend_Service_ReCaptcha
Set the ip property
Name | Type | Description |
---|---|---|
$ip | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |


setOption(string $key, string $value) : \Zend_Service_ReCaptcha
Set a single option
Name | Type | Description |
---|---|---|
$key | string | |
$value | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |


setOptions(array | \Zend_Config $options) : \Zend_Service_ReCaptcha
Set options
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |
Exception | Description |
---|---|
\Zend_Service_ReCaptcha_Exception |


setParam(string $key, string $value) : \Zend_Service_ReCaptcha
Set a single parameter
Name | Type | Description |
---|---|---|
$key | string | |
$value | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |


setParams(array | \Zend_Config $params) : \Zend_Service_ReCaptcha
Set parameters
Name | Type | Description |
---|---|---|
$params | array | \Zend_Config |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |
Exception | Description |
---|---|
\Zend_Service_ReCaptcha_Exception |


setPrivateKey(string $privateKey) : \Zend_Service_ReCaptcha
Set the private key
Name | Type | Description |
---|---|---|
$privateKey | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |


setPublicKey(string $publicKey) : \Zend_Service_ReCaptcha
Set the public key
Name | Type | Description |
---|---|---|
$publicKey | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha |


verify(string $challengeField, string $responseField) : \Zend_Service_ReCaptcha_Response
Verify the user input
This method calls up the post method and returns a Zend_Service_ReCaptcha_Response object.
Name | Type | Description |
---|---|---|
$challengeField | string | |
$responseField | string |
Type | Description |
---|---|
\Zend_Service_ReCaptcha_Response |