承接 fsorge/cloudflare-turnstile-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

fsorge/cloudflare-turnstile-php

最新稳定版本:1.0.0

Composer 安装命令:

composer require fsorge/cloudflare-turnstile-php

包简介

Validate Cloudflare Turnstile captchas with ease

README 文档

README

An unofficial PHP package to validate Cloudflare Turnstile captchas with ease. Read more at the Cloudflare official documentation.

Requirements

  • PHP >= 8.1

Getting started

  1. Download this package with Composer
composer require fsorge/cloudflare-turnstile-php
  1. Create a new Turnstile instance
use Fsorge\Cloudflare\Turnstile;

$turnstile = new Turnstile('YOUR_SECRET_KEY');
  1. Call the isValid() method
$isCaptchaValid = $turnstile->isValid('RESPONSE_FROM_CLIENT');
  1. That's it!

Dictionary

  • YOUR_SECRET_KEY: you can retrieve your secret key by going to your Cloudflare Turnstile dashboard, clicking "Settings" on your website, expanding the "Secret key" section and copying the key somewhere in your project and passing it to the Turnstile constructor
  • RESPONSE_FROM_CLIENT: it's a hidden field (with the name attribute set to cf-turnstile-response) that the Turnstile client-side widget automatically creates in your form. You have to pass that field's value.

Full simple example

use Fsorge\Cloudflare\Turnstile;

$turnstile = new Turnstile('0x......');

$isCaptchaValid = $turnstile->isValid('0.id8uAhu.....');

if ($isCaptchaValid) {
    // Captcha has been validated
} else {
    // Captcha NOT validate
}

Detailed response

If you need to have the full response from the Cloudflare Turnstile API, you can call the validate() method instead of the isValid().

validate() returns an associative array with the whole response from the Cloudflare API, containing useful information like occurred errors if any.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固