Verify CAPTCHA
This commit is contained in:
parent
946b30b486
commit
9b3c970bba
7 changed files with 132 additions and 58 deletions
33
src/Service/CaptchaVerifier.php
Normal file
33
src/Service/CaptchaVerifier.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
class CaptchaVerifier
|
||||
{
|
||||
public function isVerified(string $solution, string $secret, string $sitekey)
|
||||
{
|
||||
$url = "https://api.friendlycaptcha.com/api/v1/siteverify";
|
||||
$data = array(
|
||||
'solution' => $solution,
|
||||
'secret'=> $secret,
|
||||
'sitekey'=> $sitekey,
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'content' => json_encode( $data ),
|
||||
'header'=> "Content-Type: application/json\r\n" .
|
||||
"Accept: application/json\r\n"
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create( $options );
|
||||
$result = file_get_contents( $url, false, $context );
|
||||
$response = json_decode( $result );
|
||||
|
||||
$isVerified = $response->success;
|
||||
|
||||
return $isVerified;
|
||||
}
|
||||
}
|
Reference in a new issue