Skip to content

Instantly share code, notes, and snippets.

@Cannonb4ll
Created November 15, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cannonb4ll/dadf0262c189b486802eba35d445c980 to your computer and use it in GitHub Desktop.
Save Cannonb4ll/dadf0262c189b486802eba35d445c980 to your computer and use it in GitHub Desktop.
ReCaptcha Laravel Google
<?php
namespace App\Validators;
use GuzzleHttp\Client;
class ReCaptcha
{
public function validate($attribute, $value, $parameters, $validator)
{
$client = new Client;
$response = $client->post('https://www.google.com/recaptcha/api/siteverify',
[
'form_params' =>
[
'secret' => env('GOOGLE_RECAPTCHA_SECRET'),
'response' => $value
]
]
);
$body = json_decode((string)$response->getBody());
return $body->success;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment