/** * Calls the reCAPTCHA siteverify API to verify whether the user passes * CAPTCHA test. * * @param string $response The value of 'g-recaptcha-response' in the submitted form. * @param string $remoteIp The end user's IP address. * @return Response Response from the service. */ public function verify($response, $remoteIp = null) { // Discard empty solution submissions if (empty($response)) { $recaptchaResponse = new Response(false, array('missing-input-response')); return $recaptchaResponse; } $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); $rawResponse = $this->requestMethod->submit($params); return Response::fromJson($rawResponse); }
/** * @param string $id Form identifier * @param HttpUrl $action form action (url to which it will be sumbitted); may be null * @param RequestMethod $method action method, default is get */ function __construct($id, HttpUrl $action, RequestMethod $method = null) { Assert::isScalar($id); $this->id = $id; $this->action = $action; $this->method = $method ? $method : RequestMethod::get(); $this->enctype = new FormEnctype(FormEnctype::ENCODED); }
/** * @param string $id Form identifier * @param HttpUrl $action form action (url to which it will be sumbitted) * @param string $sign form signature to protect it from vulnerabilities; */ function __construct($id, HttpUrl $action, $sign) { $this->signer = new XorCipherer($sign); parent::__construct($id, $action, RequestMethod::post()); }