20 lines
470 B
PHP
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);
|
||
|
}
|
||
|
}
|