You are here

public function ReCaptcha::verify in reCAPTCHA 6.2

Same name and namespace in other branches
  1. 8.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::verify()
  2. 7.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::verify()

Calls the reCAPTCHA siteverify API to verify whether the user passes CAPTCHA test.

Parameters

string $response The value of 'g-recaptcha-response' in the submitted form.:

string $remoteIp The end user's IP address.:

Return value

Response Response from the service.

File

recaptcha-php/src/ReCaptcha/ReCaptcha.php, line 85

Class

ReCaptcha
reCAPTCHA client.

Namespace

ReCaptcha

Code

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);
}