soko-web/src/Util/CaptchaValidator.php
Pőcze Bence a17a88e9d4
All checks were successful
soko-web/pipeline/head This commit looks good
initial commit for soko-web
2023-04-07 19:32:15 +02:00

20 lines
470 B
PHP

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