reCAPTCHA is a free service provided by Google that protects your site from spam and abuse. The reCAPTCHA 2.0 is the newer version of reCAPTCHA developed by Google.
In this version, we don't have to download any extension code or module. We can easily render the widget by calling the google reCAPTCHA api.js in our view.
To use it in your site, you need to have valid site key and secret key for it. You can get them by registering yourself at https://www.google.com/recaptcha
Current Version: 2.0
- Yii 1.1 or above
Make sure you have your site key and secret key from Google reCAPTCHA
In the view:
Put this script code before/after your form:
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
Next, to display the widget you have to put this code inside your form:
<form> .. <div class="g-recaptcha" data-sitekey="your_site_key"></div> .. </form>
Your widget will be displayed when you open your page.
If you want to explicitly render the widget (to use callback etc) you can find the documentation provided by Google in this link