public function ReCaptcha::__construct in reCAPTCHA 6.2
Same name and namespace in other branches
- 8.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::__construct()
- 7.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::__construct()
Create a configured instance to use the reCAPTCHA service.
Parameters
string $secret shared secret between site and reCAPTCHA server.:
RequestMethod $requestMethod method used to send the request. Defaults to POST.:
File
- recaptcha-php/
src/ ReCaptcha/ ReCaptcha.php, line 58
Class
- ReCaptcha
- reCAPTCHA client.
Namespace
ReCaptchaCode
public function __construct($secret, RequestMethod $requestMethod = null) {
if (empty($secret)) {
throw new \RuntimeException('No secret provided');
}
if (!is_string($secret)) {
throw new \RuntimeException('The provided secret must be a string');
}
$this->secret = $secret;
if (!is_null($requestMethod)) {
$this->requestMethod = $requestMethod;
}
else {
$this->requestMethod = new RequestMethod\Post();
}
}