RecaptchaValidator
in package
Validates Google reCAPTCHA v2 responses via the siteverify API.
Tags
Table of Contents
Constants
- TIMEOUT_SECONDS = 3
- VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'
Methods
- validate() : bool
- Validate a reCAPTCHA response token
Constants
TIMEOUT_SECONDS
private
mixed
TIMEOUT_SECONDS
= 3
VERIFY_URL
private
mixed
VERIFY_URL
= 'https://www.google.com/recaptcha/api/siteverify'
Methods
validate()
Validate a reCAPTCHA response token
public
validate(string $token[, string $clientIp = '' ]) : bool
Parameters
- $token : string
-
The g-recaptcha-response value from the form
- $clientIp : string = ''
-
The client IP address (optional, sent to Google)
Return values
bool —True if Google confirms the token is valid