class RequestParameters in reCAPTCHA 7.2
Same name and namespace in other branches
- 8.2 recaptcha-php/src/ReCaptcha/RequestParameters.php \ReCaptcha\RequestParameters
- 6.2 recaptcha-php/src/ReCaptcha/RequestParameters.php \ReCaptcha\RequestParameters
Stores and formats the parameters for the request to the reCAPTCHA service.
Hierarchy
- class \ReCaptcha\RequestParameters
Expanded class hierarchy of RequestParameters
7 files declare their use of RequestParameters
- CurlPost.php in recaptcha-php/
src/ ReCaptcha/ RequestMethod/ CurlPost.php - CurlPostTest.php in recaptcha-php/
tests/ ReCaptcha/ RequestMethod/ CurlPostTest.php - Drupal7Post.php in src/
ReCaptcha/ RequestMethod/ Drupal7Post.php - Custom Drupal 7 RequestMehod class for Google reCAPTCHA library.
- Post.php in recaptcha-php/
src/ ReCaptcha/ RequestMethod/ Post.php - PostTest.php in recaptcha-php/
tests/ ReCaptcha/ RequestMethod/ PostTest.php
File
- recaptcha-php/
src/ ReCaptcha/ RequestParameters.php, line 32
Namespace
ReCaptchaView source
class RequestParameters {
/**
* The shared key between your site and reCAPTCHA.
* @var string
*/
private $secret;
/**
* The user response token provided by reCAPTCHA, verifying the user on your site.
* @var string
*/
private $response;
/**
* Remote user's IP address.
* @var string
*/
private $remoteIp;
/**
* Client version.
* @var string
*/
private $version;
/**
* Initialise parameters.
*
* @param string $secret Site secret.
* @param string $response Value from g-captcha-response form field.
* @param string $remoteIp User's IP address.
* @param string $version Version of this client library.
*/
public function __construct($secret, $response, $remoteIp = null, $version = null) {
$this->secret = $secret;
$this->response = $response;
$this->remoteIp = $remoteIp;
$this->version = $version;
}
/**
* Array representation.
*
* @return array Array formatted parameters.
*/
public function toArray() {
$params = array(
'secret' => $this->secret,
'response' => $this->response,
);
if (!is_null($this->remoteIp)) {
$params['remoteip'] = $this->remoteIp;
}
if (!is_null($this->version)) {
$params['version'] = $this->version;
}
return $params;
}
/**
* Query string representation for HTTP request.
*
* @return string Query string formatted parameters.
*/
public function toQueryString() {
return http_build_query($this
->toArray(), '', '&');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RequestParameters:: |
private | property | Remote user's IP address. | |
RequestParameters:: |
private | property | The user response token provided by reCAPTCHA, verifying the user on your site. | |
RequestParameters:: |
private | property | The shared key between your site and reCAPTCHA. | |
RequestParameters:: |
private | property | Client version. | |
RequestParameters:: |
public | function | Array representation. | |
RequestParameters:: |
public | function | Query string representation for HTTP request. | |
RequestParameters:: |
public | function | Initialise parameters. |