RECAPTCHA_API_SERVER
RECAPTCHA_API_SERVER
PHP Library for reCAPTCHA Google's API.
Captcha class that handles calling Google's reCAPTCHA API widget.
custom_theme(string $widget_id) : string
Custom Theme Template In order to use a custom theme, you must set reCAPTCHA options correctly, also provide a custom CSS to display it properly.
Fully custom theme reference: {@link: https://developers.google.com/recaptcha/docs/customization#Custom_Theming}
string | $widget_id | The ID name for wrapper container |
setTranslation(string $language, string $path) : void
Custom Translations
In order to use custom translation (even if it is not built in specially for a custom theme), the translations must be set manually by this method or by passing the lang two letters code to instance constructor. It will set translation by a lang code given and overwrites other languages set in an external captcha_config file.
NOTE: If translate file recaptcha.lang[lang_code].php with its respective translation strings within a folder i18n is not found a default lang English 'en' will be used instead.
To use an external file for a custom lang translation you must create a copy of some lang file already done within the folder I18n and rename it as 'recaptcha.lang[lang_code].php' place it wherever you want and tell as second parameter its absolute $path without filename
string | $language | Two letter language code e.g: (Italian = 'it') |
string | $path | Optional path to translate file |
setConfig(string $config_location) : void
Set global reCAPTCHA options by loading an external config file these options can be set for all instances of reCAPTCHA in your app, this avoid to set options, private and public Keys all the time individualy within your forms that has a Captcha widget.
string | $config_location | The absolute path to config file |
setError(string $e) : void
Set reCAPTCHA server Response error.
NOTE: Default string error is: incorrect-captcha-sol Use this function to overwrite with your own message.
string | $e | The error message string. Optional Whether this parameter is NULL, it will retrieve
|
displayHTML(string $theme_name, array $options) : string
Create embedded widget script HTML called within a form
NOTE: $theme_name is used to set theme name separated instead set it within array of options available, this is to keep compatibility for newer version in future.
string | $theme_name | Optional Standard_Theme or custom theme name |
array | $options | Optional array of reCAPTCHA options |
The reCAPTCHA widget embed HTML
_theme(string $theme_name, array $options) : string
Standard Theme Display's Theme customization for reCAPTCHA widget by writting a snippet for Standard_Themes and Custom_Theming
string | $theme_name | Optional theme name. NOTE: overwrite theme if it's set in an external config |
array | $options | reCAPTCHA Associative array of available options. NOTE: overwrite options set in an external config |
Standard_Theme | Custom_Theme | Fallback default reCAPTCHA theme
_postHttpChallenge(array $data) : array
reCAPTCHA API Request
Post reCAPTCHA input challenge, response Uses function fsockopen() and curl() as a fallback If both functions are unavailable in server configuration an {@link \ReCaptcha\CaptchaException} exception will be thrown
array | $data | Array of reCAPTCHA parameters |