You are here

public function SocketPost::__construct in reCAPTCHA 8.2

Same name and namespace in other branches
  1. 6.2 recaptcha-php/src/ReCaptcha/RequestMethod/SocketPost.php \ReCaptcha\RequestMethod\SocketPost::__construct()
  2. 7.2 recaptcha-php/src/ReCaptcha/RequestMethod/SocketPost.php \ReCaptcha\RequestMethod\SocketPost::__construct()

Only needed if you want to override the defaults

Parameters

\ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing:

string $siteVerifyUrl URL for reCAPTCHA sitevrerify API:

File

recaptcha-php/src/ReCaptcha/RequestMethod/SocketPost.php, line 52

Class

SocketPost
Sends a POST request to the reCAPTCHA service, but makes use of fsockopen() instead of get_file_contents(). This is to account for people who may be on servers where allow_url_open is disabled.

Namespace

ReCaptcha\RequestMethod

Code

public function __construct(Socket $socket = null, $siteVerifyUrl = null) {
  $this->socket = is_null($socket) ? new Socket() : $socket;
  $this->siteVerifyUrl = is_null($siteVerifyUrl) ? ReCaptcha::SITE_VERIFY_URL : $siteVerifyUrl;
}