Files
backend/src/Service/Client/SmartCaptchaClientService.php
T
2026-05-27 19:36:32 +03:00

34 lines
890 B
PHP

<?php
namespace App\Service\Client;
use App\Service\Client\AbstractHttpClientService;
use App\Service\Client\Interfaces\SmartCaptchaClientServiceInterface;
final class SmartCaptchaClientService extends AbstractHttpClientService implements SmartCaptchaClientServiceInterface
{
private string $secret;
public function __construct(string $userAgent, string $baseUrl, string $secret)
{
parent::__construct($userAgent, $baseUrl);
$this->secret = $secret;
}
public function validate(string $token, string $clientIp): array
{
$options = [
'query' => [
"secret" => $this->secret,
"token" => $token,
"ip" => $clientIp,
]
];
$httpResponse = $this->request('POST', '/validate', $options);
return $httpResponse->toArray();
}
}