soko-web/src/Util/CaptchaValidator.php

20 lines
470 B
PHP
Raw Normal View History

2023-04-07 19:32:15 +02:00
<?php namespace SokoWeb\Util;
use SokoWeb\Http\Request;
class CaptchaValidator
{
public function validate(string $response)
{
$request = new Request('https://www.google.com/recaptcha/api/siteverify', Request::HTTP_GET);
$request->setQuery([
'secret' => $_ENV['RECAPTCHA_SECRET'],
'response' => $response
]);
$response = $request->send();
return json_decode($response->getBody(), true);
}
}