http = $http; $this->secret = $secret; $this->sitekey = $sitekey; } public function responseField(): string { return 'h-captcha-response'; } public function verify(string $response, ?string $remote_ip): bool { $data = [ 'secret' => $this->secret, 'response' => $response, 'sitekey' => $this->sitekey ]; if ($remote_ip !== null) { $data['remoteip'] = $remote_ip; } $ret = $this->http->requestGet('https://hcaptcha.com/siteverify', $data); $resp = \json_decode($ret, true, 16, \JSON_THROW_ON_ERROR); return isset($resp['success']) && $resp['success']; } }