项目作者: paragasu

项目描述 :
lua recaptcha
高级语言: Lua
项目地址: git://github.com/paragasu/lua-recaptcha.git
创建时间: 2017-03-20T06:41:20Z
项目社区:https://github.com/paragasu/lua-recaptcha

开源协议:

下载


lua-recaptcha

Google backend implementation for lua.

Installation

  1. #luarocks install lua-recaptcha

Client side integration

Paste the following snippet in the HEAD section

  1. <script src='https://www.google.com/recaptcha/api.js'></script>

Paste the following at the end of the form. You need to specify the callback function to
handle the result.

  1. <button class="g-recaptcha" data-sitekey="<your-site-key>" data-callback="YourOnSubmitFn"> Submit </button>

API

new(site_key, secret_key)

  • param site_key string from google dashboard
  • param secret_key string from google dashboard

valid(g_captcha_response, remote_ip)

  • param g_captcha_reponse string the value of g-captcha-response
  • param remote_ip string client remote ip address
  • return boolean

Usage

  1. local recaptcha = require 'recaptcha'
  2. local captcha = recaptcha:new(site_key, secret_key)
  3. if captcha.valid(g_captcha_response, remote_ip) then
  4. ngx.say('valid captcha')
  5. end

Reference

Recaptcha API