a simple Clojure client for [reCAPTCHA] 1 API (v1.0 and v2.0).
Include the library in your leiningen project dependencies:
[clj-recaptcha "0.0.2"]
To make the reCAPTCHA widget appear when your page loads, you will need to insert a snippet of JavaScript & non-JavaScript code in your <form>
element. To generate the snippet, use:
(ns your.namespace
(:require [clj-recaptcha.client :as c]))
(c/render "your-public-key" :ssl? true :display {:theme "clean" :lang "de"})
Optional parameters:
(ns your.namespace
(:require [clj-recaptcha.client-v2 :as c]))
(c/render "your-public-key")
After your page is successfully displaying reCAPTCHA, you need to configure your form to check whether the answers entered by the users are correct. Here's how it can be done:
(ns your.namespace
(:require [clj-recaptcha.client :as c]))
(c/verify "your-private-key" "challenge" "response" "127.0.0.1")
;; {:valid? false :error "incorrect-captcha-sol"}
Optional parameters:
(ns your.namespace
(:require [clj-recaptcha.client-v2 :as c]))
(c/verify "your-private-key" "response" :remote-ip "127.0.0.1")
;; {:valid? false :error "incorrect-captcha-sol"}
Optional parameters:
For better performance, you can use a pooled connection manager, that can be passed via :connection-manager option. To create a connection manager:
(create-conn-manager {:threads 5})
It's just a shortcut for clj-http.conn-mgr/make-reusable-conn-manager
, check [clj-http] 2 documentation for more details.
Copyright © 2013 Pavel Prokopenko
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation? These fine people already did:
Pavel Prokopenko & Carlos CunhaEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close