tekintian/tekintcaptcha 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tekintian/tekintcaptcha

最新稳定版本:v1.0.1

Composer 安装命令:

composer require tekintian/tekintcaptcha

包简介

腾讯验证码, 腾讯防水墙, 验证码, 滑动验证码, 智能滑动验证码PHP扩展, TekinTCaptcha - A Client library for Tencent Captcha, a service that protect websites from spam and abuse.

README 文档

README

基于Google PHP项目设计思想实现的腾讯滑动智能验证码实现PHP中间件。

Description

腾讯验证码, 腾讯防水墙, 验证码, 滑动验证码, 智能滑动验证码PHP扩展, TekinTCaptcha - A Client library for Tencent Captcha, a service that protect websites from spam and abuse. TekinTCaptcha is a free CAPTCHA service that protect websites from spam and abuse.

This is Tencent Captcha code that provides plugins for third-party integration with TekinTCaptcha.

Installation

Composer (Recommended)

Composer is a widely used dependency manager for PHP packages. This TekinTCaptcha client is available on Packagist as tekintian/tekintcaptcha and can be installed either by running the composer require command or adding the library to your composer.json. To enable Composer for you project, refer to the project's Getting Started documentation.

To add this dependency using the command, run the following from within your project directory:

composer require tekintian/tekintcaptcha "~1.0"

Alternatively, add the dependency directly to your composer.json file:

"require": {
    "tekintian/tekintcaptcha": "~1.0"
}

Direct download (no Composer)

If you wish to install the library manually (i.e. without Composer), then you can use the links on the main project page to either clone the repo or download the ZIP file. For convenience, an autoloader script is provided in src/autoload.php which you can require into your script instead of Composer's vendor/autoload.php. For example:

require('/path/to/TekinTCaptcha/src/autoload.php');
$recaptcha = new \TekinTCaptcha\TekinTCaptcha($aid,$AppSecretKey);

The classes in the project are structured according to the PSR-4 standard, so you may of course also use your own autoloader or require the needed files directly in your code.

Usage

First, register keys for your site at http://007.qq.com

When your app receives a form submission containing the Ticket, Randstr field, you can verify it using:

<?php
$recaptcha = new \TekinTCaptcha\TekinTCaptcha($aid,$AppSecretKey);
$resp = $recaptcha->verify($Ticket, $Randstr, $UserIP);
if ($resp->isSuccess()) {
    // verified!
    // if Domain Name Validation turned off don't forget to check hostname field
    // if($resp->getStatus() === 1) {  }
} else {
    $errors = $resp->getErrMsg();
}

You can see an end-to-end working example in examples/index.html examples/login.php

thinkphp5 demo

conposer require tekintian/tekintcaptcha

//腾讯验证码配置 for config.php / app.php
    'tenncent_cpatcha'     => [ 
        'aid' => '123456',
        'app_secret_key' => 'aaaaadfasdfdsfsdf**',
    ]

//for login.php
 public function login()
    {
       // 指定模板输出
        return $this->fetch('login');
    }
    public function doLogin(){
         $post = input('param.'); // 获取全部参数
        if (isset($post['Ticket']) && $post['Ticket'] !='' ) {
            /*从tp5的配置文件中读取aid, AppSecretKey */
            $aid=config('app.tenncent_cpatcha.aid');
            $AppSecretKey=config('app.tenncent_cpatcha.app_secret_key');
            /*实例化 TekinTCaptcha */
            $captcha = new \TekinTCaptcha\TekinTCaptcha($aid,$AppSecretKey);
            /*验证票据*/
            $resp = $captcha->verify($post['Ticket'], $post['Randstr']);
  
            if ($resp->isSuccess()){
                //验证成功
                pp($post);

                //验证成功end
            }else{
                foreach ($resp->getErrMsg() as $msg) {
                    echo '<kbd>' , $msg , '</kbd> ';
                 }
                echo '<kbd>返回状态码:'. $resp->getStatus() .'</kbd> ';
                echo '<kbd>恶意等级:'. $resp->getEvilLevel() .'</kbd> ';
            }

        }

    }

打赏赞助 Donate

Donate with alipay

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-07-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固