autrobin / recaptcha-v3

PHP Integration for reCAPTCHA v3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reCAPTCHA v3 PHP Server Library

Latest Stable Version Total Downloads Build Status codecov License

Simple server check implementation for reCAPTCHA v3

Note: This is a Beta version of reCAPTCHA which is still undergoing final testing before its official release. The API, documentation, and policy are subject to change in the future.

Installation

composer require wearesho-team/recaptcha-v3

Usage

See example.php for details

<?php

use Wearesho\ReCaptcha;

$response = $_POST['g-recaptcha-response'];
$ip = $_SERVER['REMOTE_ADDR'] ?? null;

$config = new ReCaptcha\V3\Config($secret = "...");
$client = new ReCaptcha\V3\Client($config);

try {
    $response = $client->verify($response, $ip);
} catch (ReCaptcha\V3\Exception $e) {
    $response = $e->getResponse();
    // do something if token is not valid
}

$response->getScore(); // score from 0 to 1

Contributors

License

MIT

About

PHP Integration for reCAPTCHA v3

License:MIT License


Languages

Language:PHP 100.0%