aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <Justmichael@mail.ru>2015-08-29 10:54:26 +0500
committerMichael <Justmichael@mail.ru>2015-08-29 10:54:26 +0500
commit6b7c3b2e76c3986f536d4126557acab6b3a93895 (patch)
treee7052f8567a6e12f604fec2bc7e2fc7de33012ea
parent4a0dbe0e1a26400c59f678cd87c437b44605344a (diff)
downloadrecaptcha-6b7c3b2e76c3986f536d4126557acab6b3a93895.tar.gz
recaptcha-6b7c3b2e76c3986f536d4126557acab6b3a93895.tar.xz
Update README.md
-rw-r--r--README.md40
1 files 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
<form name="someform" method="post" action="/somewhere">
@@ -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).