定制 mcnub/nextcaptcha-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mcnub/nextcaptcha-laravel

最新稳定版本:1.0.1

Composer 安装命令:

composer require mcnub/nextcaptcha-laravel

包简介

NextCaptcha integration for Laravel

README 文档

README

Features

  • reCAPTCHA v2

  • reCAPTCHA v2 Enterprise

  • reCAPTCHA v2 HS Enterprise

  • reCAPTCHA v3

  • reCAPTCHA v3 HS

  • Laravel Facade for easy usage

  • Configurable through Laravel's configuration system

  • Comprehensive logging support

  • Proxy support

  • Full TypeScript support for response types

Requirements

  • PHP 8.1 or higher
  • Laravel 9.0 or higher
  • Guzzle 7.5 or higher

Installation

You can install the package via composer:

composer require mcnub/nextcaptcha-laravel

After installing, publish the configuration file:

php artisan vendor:publish --tag=nextcaptcha-config

Configuration

Configure your NextCaptcha credentials in your .env file:

NEXTCAPTCHA_CLIENT_KEY=your-api-key
NEXTCAPTCHA_TIMEOUT=45

Usage

Basic Usage

Using the Facade:

use NextCaptcha\Facades\NextCaptcha;

// Solve reCAPTCHA v2
$result = NextCaptcha::recaptchaV2(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key'
);

// Get balance
$balance = NextCaptcha::getBalance();

Using Dependency Injection:

use NextCaptcha\NextCaptchaAPI;

class CaptchaController extends Controller
{
    public function __construct(
        private NextCaptchaAPI $captcha
    ) {}

    public function solve()
    {
        $result = $this->captcha->recaptchaV2(
            websiteUrl: 'https://example.com',
            websiteKey: 'site-key'
        );
        
        return response()->json($result);
    }
}

Available Methods

reCAPTCHA v2

$result = NextCaptcha::recaptchaV2(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    recaptchaDataSValue: '',  // optional
    isInvisible: false,       // optional
    apiDomain: '',           // optional
    pageAction: '',          // optional
    websiteInfo: ''          // optional
);

reCAPTCHA v2 Enterprise

$result = NextCaptcha::recaptchaV2Enterprise(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    enterprisePayload: [],    // optional
    isInvisible: false,       // optional
    apiDomain: '',           // optional
    pageAction: '',          // optional
    websiteInfo: ''          // optional
);

reCAPTCHA v3

$result = NextCaptcha::recaptchaV3(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    pageAction: '',          // optional
    apiDomain: '',           // optional
    proxyType: '',          // optional
    proxyAddress: '',       // optional
    proxyPort: 0,           // optional
    proxyLogin: '',         // optional
    proxyPassword: '',      // optional
    websiteInfo: ''         // optional
);

hCaptcha

$result = NextCaptcha::hCaptcha(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    isInvisible: false,      // optional
    enterprisePayload: [],   // optional
    proxyType: '',          // optional
    proxyAddress: '',       // optional
    proxyPort: 0,           // optional
    proxyLogin: '',         // optional
    proxyPassword: ''       // optional
);

Testing

composer test

Security Vulnerabilities

If you discover a security vulnerability within NextCaptcha Laravel, please send an e-mail to security@example.com. All security vulnerabilities will be promptly addressed.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-21