Blesta Source Documentation

ReCaptcha extends AbstractCaptcha

Google reCAPTCHA integration

Table of Contents

Properties

$Html
$apiUrl
$options

Methods

__construct() Initialize ReCaptcha
buildHtml() Builds the HTML content to render the reCaptcha
errors() Retrieves any errors associated with the captcha
getName() Returns the name of the captcha provider
getOptionFields() Gets a list of the options input fields
setOptions() Sets reCaptcha options
verify() Verifies whether or not the captcha is valid
setErrors() Sets the given errors
Properties

$apiUrl

private string $apiUrl = 'https://www.google.com/recaptcha/api.js'

The Google reCaptcha JavaScript API URL

$options

private array<string|int, mixed> $options = []

An array of options

Methods

__construct()

Initialize ReCaptcha

public __construct() : mixed

buildHtml()

Builds the HTML content to render the reCaptcha

public buildHtml() : string
Return values
string

The HTML

errors()

Retrieves any errors associated with the captcha

public errors() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of errors

getName()

Returns the name of the captcha provider

public getName() : string
Return values
string

The name of the captcha provider

getOptionFields()

Gets a list of the options input fields

public getOptionFields([array<string|int, mixed> $vars = [] ]) : InputFields
Parameters
$vars : array<string|int, mixed> = []

An array containing the posted fields

Return values
InputFields

An object representing the list of input fields

setOptions()

Sets reCaptcha options

public setOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

An array of options including:

  • site_key The reCaptcha site key
  • shared_key The reCaptcha shared key
  • lang The user's language (e.g. "en" for English)
  • ip_address The user's IP address (optional)

verify()

Verifies whether or not the captcha is valid

public verify(array<string|int, mixed> $data) : bool
Parameters
$data : array<string|int, mixed>

An array of data to validate against, including:

  • response The value of 'g-recaptcha-response' in the submitted form
Return values
bool

Whether or not the captcha is valid

setErrors()

Sets the given errors

protected setErrors(array<string|int, mixed> $errors) : mixed
Parameters
$errors : array<string|int, mixed>

An array of error messages in the format:

  • ['name' => ['type' => 'Error Message']]
Tags
subpackage

core.Util.Captcha.Captchas

copyright

Copyright (c) 2019, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results