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