PHP code example of tekintian / tekintcaptcha

1. Go to this page and download the library: Download tekintian/tekintcaptcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tekintian / tekintcaptcha example snippets



$recaptcha = new \TekinTCaptcha\TekinTCaptcha($aid,$AppSecretKey);


$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();
}

//腾讯验证码配置 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> ';
            }

        }

    }