Service/ReCaptcha.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
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 [email protected] so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Service  
Subpackage
ReCaptcha  

\Zend_Service_ReCaptcha

Package: Zend_Service\ReCaptcha
Zend_Service_ReCaptcha
Parent(s)
\Zend_Service_Abstract
Children
\Zend_Service_ReCaptcha_MailHide
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Version
$Id$  

Constants

>VConstantstring  API_SERVER = 'http://www.google.com/recaptcha/api'
URI to the regular API
API_SERVER
string

>VConstantstring  API_SECURE_SERVER = 'https://www.google.com/recaptcha/api'
URI to the secure API
API_SECURE_SERVER
string

>VConstantstring  VERIFY_SERVER = 'http://www.google.com/recaptcha/api/verify'
URI to the verify server
VERIFY_SERVER
string

Properties

>VPropertyprotectedstring $_ip = null
Ip address used when verifying user input
Default valuenullDetails
Type
string
>VPropertyprotectedarray $_options = array('theme' => 'red', 'lang' => 'en', 'custom_translations' => array())
Options for tailoring reCaptcha
See the different options on http://recaptcha.net/apidocs/captcha/client.html
Default valuearray('theme' => 'red', 'lang' => 'en', 'custom_translations' => array())Details
Type
array
>VPropertyprotectedarray $_params = array('ssl' => false, 'error' => null, 'xhtml' => false)
Parameters for the object
Default valuearray('ssl' => false, 'error' => null, 'xhtml' => false)Details
Type
array
>VPropertyprotectedstring $_privateKey = null
Private key used when verifying user input
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_publicKey = null
Public key used when displaying the captcha
Default valuenullDetails
Type
string
>VPropertyprotected\Zend_Service_ReCaptcha_Response $_response = null
Response from the verify server
Default valuenullDetails
Type
\Zend_Service_ReCaptcha_Response

Methods

methodpublic__construct(string $publicKey = null, string $privateKey = null, array | array | \Zend_Config $params = null, array $options = null, string $ip = null) : void

Class constructor

Parameters
NameTypeDescription
$publicKeystring
$privateKeystring
$paramsarray | array | \Zend_Config
$optionsarray
$ipstring
methodpublic__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.
Returns
TypeDescription
string
methodprotected_post(string $challengeField, string $responseField) : \Zend_Http_Response

Post a solution to the verify server

Parameters
NameTypeDescription
$challengeFieldstring
$responseFieldstring
Returns
TypeDescription
\Zend_Http_Response
Throws
ExceptionDescription
\Zend_Service_ReCaptcha_Exception
methodpublicgetHtml(null | string $name = null) : string

Get the HTML code for the captcha

This method uses the public key to fetch a recaptcha form.
Parameters
NameTypeDescription
$namenull | string

Base name for recaptcha form elements

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Service_ReCaptcha_Exception
methodpublicgetIp() : string

Get the ip property

Returns
TypeDescription
string
methodpublicgetOption(string $key) : mixed

Get a single option

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetOptions() : array

Get the options array

Returns
TypeDescription
array
methodpublicgetParam(string $key) : mixed

Get a single parameter

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetParams() : array

Get the parameter array

Returns
TypeDescription
array
methodpublicgetPrivateKey() : string

Get the private key

Returns
TypeDescription
string
methodpublicgetPublicKey() : string

Get the public key

Returns
TypeDescription
string
methodpublicsetIp(string $ip) : \Zend_Service_ReCaptcha

Set the ip property

Parameters
NameTypeDescription
$ipstring
Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicsetOption(string $key, string $value) : \Zend_Service_ReCaptcha

Set a single option

Parameters
NameTypeDescription
$keystring
$valuestring
Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicsetOptions(array | \Zend_Config $options) : \Zend_Service_ReCaptcha

Set options

Parameters
NameTypeDescription
$optionsarray | \Zend_Config
Returns
TypeDescription
\Zend_Service_ReCaptcha
Throws
ExceptionDescription
\Zend_Service_ReCaptcha_Exception
methodpublicsetParam(string $key, string $value) : \Zend_Service_ReCaptcha

Set a single parameter

Parameters
NameTypeDescription
$keystring
$valuestring
Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicsetParams(array | \Zend_Config $params) : \Zend_Service_ReCaptcha

Set parameters

Parameters
NameTypeDescription
$paramsarray | \Zend_Config
Returns
TypeDescription
\Zend_Service_ReCaptcha
Throws
ExceptionDescription
\Zend_Service_ReCaptcha_Exception
methodpublicsetPrivateKey(string $privateKey) : \Zend_Service_ReCaptcha

Set the private key

Parameters
NameTypeDescription
$privateKeystring
Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicsetPublicKey(string $publicKey) : \Zend_Service_ReCaptcha

Set the public key

Parameters
NameTypeDescription
$publicKeystring
Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicverify(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.
Parameters
NameTypeDescription
$challengeFieldstring
$responseFieldstring
Returns
TypeDescription
\Zend_Service_ReCaptcha_Response
Documentation was generated by phpDocumentor 2.2.0 .