From 6b7c3b2e76c3986f536d4126557acab6b3a93895 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Aug 2015 10:54:26 +0500 Subject: Update README.md --- README.md | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f789b78..aec4575 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ A simple Elixir package for implementing [reCAPTCHA] in [Phoenix] applications. 2. List `:recaptcha` as an application dependency ```elixir -def application do - [ applications: [:phoenix, :recaptcha] ] -end + def application do + [ applications: [:phoenix, :recaptcha] ] + end ``` 3. Run `mix do deps.get, compile` @@ -33,8 +33,8 @@ end Set default public and private keys in your application's config.exs ```elixir -config :recaptcha, - api_config: %{ verify_url: "https://www.google.com/recaptcha/api/siteverify", + config :recaptcha, + api_config: %{ verify_url: "https://www.google.com/recaptcha/api/siteverify", public_key: "YOUR_PUBLIC_KEY", private_key: "YOUR_PRIVATE_KEY" } ``` @@ -43,7 +43,7 @@ config :recaptcha, ### View -It is required to use the `raw` method to render the captcha, like this: +Use `raw` and `Recaptcha.display` methods to render the captcha ```html
@@ -67,26 +67,38 @@ Option | Action Recaptcha provides `verify` method, that can be used like this: ```elixir -def create(conn, params) do - # some code - case Recaptcha.verify(conn.remote_ip, params["g-recaptcha-response"]) do - :ok -> do_something - :error -> handle_error + def create(conn, params) do + # some code + case Recaptcha.verify(conn.remote_ip, params["g-recaptcha-response"]) do + :ok -> do_something + :error -> handle_error + end end -end ``` `verify` method sends a `POST` request to the reCAPTCHA API and returns 2 possible values: -`:ok` -> captcha is valid +`:ok` -> The captcha is valid -`:error` -> server returned `missing-input-response` or `invalid-input-response` error codes +`:error` -> Server returned `missing-input-response` or `invalid-input-response` error codes If the server returns `missing-input-secret` or `invalid-input-secret`, `RuntimeError` is raised + `verify` method also accepts a keyword list as the third parameter with the following options: Option | Action | Default :---------------------- | :----------------------------------------------------- | :------------------------ `timeout` | Time to wait before timeout | 3000 (ms) `private_key` | Private key to send as a parameter of the API request | Private key from the config file + +## Contributing + +* Fork the project. +* Make your feature addition or bug fix. +* Commit +* Send me a pull request + +## License + +[MIT License](http://www.opensource.org/licenses/MIT). -- cgit v1.2.1