Skip to content
Derek Jones edited this page Jul 5, 2012 · 18 revisions

Category:Libraries Category:Libraries::reCAPTCHA

Description

This a CI 2.0.x implementation of the ReCAPTCHA API ( http://code.google.com/apis/recaptcha) Forum Discussion:[Here](http://codeigniter.com/forums/viewthread/67250/)

Features:

* Uses config file for saving your reCaptcha keys and theme * Uses an editable view for the reCaptcha form that can be inserted anywhere in your code * Logs errors and messages to your log files rather than to the user's screen * Multilingual support. Check http://code.google.com/apis/recaptcha/docs/customization.html#i18n for supported languages and codes. English is the only language included (other language contributions welcome) * Uploaded needed files as a zip rather than copy/paste from the wiki * Download includes a sample that only requires you to include your API Keys from recaptcha.net

Download:

File:recaptcha_2.0.0.zip

Files Included

(These all go under your system/application folder) * **config/form_validation** - enables you to add/edit any rules you may need to include if the reCaptcha is part of a larger form * **config/recaptcha** - configuration of the reCaptcha parameters * **controllers/recaptchademo** - a quick demonstration page you can use for testing * **views/recaptcha_demo** - a view to help in testing * **views/recaptcha** - the form snippet used to generate the reCaptcha to the user * **libraries/recaptcha** - The reCaptcha library * **language/english/recaptcha_lang** - language entries

Configuration

config/recaptcha

```php $config['recaptcha'] = array( 'public'=>'YOUR PUBLIC KEY', 'private'=>'YOUR PRIVATE KEY', 'RECAPTCHA_API_SERVER' =>'http://www.google.com/recaptcha/api', 'RECAPTCHA_API_SECURE_SERVER'=>'https://www.google.com/recaptcha/api', 'RECAPTCHA_VERIFY_SERVER' =>'www.google.com', 'RECAPTCHA_SIGNUP_URL' => 'https://www.google.com/recaptcha/admin/create', 'theme' => 'white' ); ```

controller

```php function index() { $this->load->library('recaptcha'); $this->load->library('form_validation'); $this->lang->load('recaptcha'); $this->load->helper('form');
if ($this->form_validation->run()) 
{
  $this->load->view('recaptcha_demo',array('recaptcha'=>'Yay! You got it right!'));
}
else
{
  //the desired language code string can be passed to the get_html() method
  //"en" is the default if you don't pass the parameter
  //valid codes can be found here:http://code.google.com/apis/recaptcha/docs/customization.html#i18n
  $this->load->view('recaptcha_demo',array('recaptcha'=>$this->recaptcha->get_html()));
}

}


Feel free to check out the other files in the library and visit the discussion to ask questions.
That's it!
Clone this wiki locally