定制 kamotelab/php-turnstile 二次开发

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

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

kamotelab/php-turnstile

最新稳定版本:v1.2.1

Composer 安装命令:

composer require kamotelab/php-turnstile

包简介

PHP implementation of cloudflare's turnstile

README 文档

README

GitHub Actions Workflow Status GitHub Release

A lightweight PHP implementation of Cloudflare's Turnstile

Requirements

Installation

 composer require kamotelab/php-turnstile

Example Usage

<?php

use KamoteLab\Turnstile;

class YourClass 
{
    private Turnstile $turnstile

    public function __construct(Turnstile $turnstile) {
        $this->turnstile = new Turnstile('{Turnstile Secret Key}');
    }
    
    /*
     * $response (required) = turnstile response from client side render on your site.
     * $idempotencyKey (optional) = use this if you need to retry failed request.
     * $remoteIp (optional) = The visitor’s IP address.
     */
    public function yourMethod(string $response, ?string $idempotencyKey = null, ?string $remoteIp = null) {
        
        try {
            $this->turnstile->verify($response, $idempotencyKey, $remoteIp)
        } catch (Exception $e) {
            // next step in case of exception
        }
        
    }
}

Disclaimer

  • This library will not throw any exception when the response code is 4xx or 5xx
  • You will have to implement your own error handling when response code is 4xx, 5xx
  • You will have to implement your own error handling when error was thrown

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-10