You are here

public function HCaptcha::validate in hCaptcha 7

File

src/HCaptcha/HCaptcha.php, line 61

Class

HCaptcha

Namespace

HCaptcha

Code

public function validate($response_token, $remote_ip = '') {
  $query = array(
    'secret' => $this->secretKey,
    'response' => $response_token,
    'remoteip' => $remote_ip,
  );
  $this->validated = $this->requestMethod
    ->submit(self::SITE_VERIFY_URL, array_filter($query));
  if (isset($this->validated->success) && $this->validated->success === true) {

    // Verified!
    $this->success = true;
  }
  else {
    $this->errors = $this
      ->getResponseErrors();
  }
}