定制 nietonfir/google-recaptcha 二次开发

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

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

nietonfir/google-recaptcha

最新稳定版本:v0.2.1

Composer 安装命令:

composer require nietonfir/google-recaptcha

包简介

Library to simplify the server-side validation of Google's 'No CAPTCHA reCAPTCHA'

README 文档

README

ReCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse. This library aims to providate an alternative to the official ReCAPTCHA library for verifying a users "No CAPTCHA reCAPTCHA" response. Internally it uses Guzzle for communicating with the ReCAPTCHA API.

Build Status Latest Stable Version Latest Unstable Version License

Installation

The recommended way to install GoogleReCaptcha is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of GoogleReCaptcha:

composer require "nietonfir/google-recaptcha"

Or add GoogleReCaptcha in your composer.json

"require": {
    "nietonfir/google-recaptcha": "~0.0"
}

and tell Composer to install the library:

composer update "nietonfir/google-recaptcha"

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Usage

A sample validation client could look like the following:

use GuzzleHttp\Client;
use Nietonfir\Google\ReCaptcha\ReCaptcha;
use Nietonfir\Google\ReCaptcha\Api\RequestData,
    Nietonfir\Google\ReCaptcha\Api\ResponseFactory;

$requestData = new RequestData(
    'YOUR_API_SECRET_HERE',         // secret
    $_POST['g-recaptcha-response'], // user response
    $_SERVER['REMOTE_ADDR']         // end user IP
);

$reCaptcha = new ReCaptcha(new Client(), new ResponseFactory());
$response = $reCaptcha->processRequest($requestData);

if ($response->isValid()) {
    // check the hostname if "Domain Name Validation" is turned off
    // if($_SERVER['SERVER_NAME'] === $response->getHostName()) { … }
    echo 'I\'m not a robot';
} else {
    var_dump($response->getErrors());
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-28