VERSION

This document describes Captcha::reCAPTCHA

SYNOPSIS

    use Captcha::reCAPTCHA;

    my $c = Captcha::reCAPTCHA->new;

    # Output form
    print $c->get_html( 'your public key here' );

    # Verify submission
    my $result = $c->check_answer(
        'your private key here', $ENV{'REMOTE_ADDR'},
        $challenge, $response
    );

    if ( $result->{is_valid} ) {
        print "Yes!";
    }
    else {
        # Error
        $error = $result->{error};
    }

For complete examples see the /examples subdirectory

DESCRIPTION

reCAPTCHA is a hybrid mechanical turk and captcha that allows visitors who complete the captcha to assist in the digitization of books.

From <http://recaptcha.net/learnmore.html>:

reCAPTCHA improves the process of digitizing books by sending words that cannot be read by computers to the Web in the form of CAPTCHAs for humans to decipher. More specifically, each word that cannot be read correctly by OCR is placed on an image and used as a CAPTCHA. This is possible because most OCR programs alert you when a word cannot be read correctly.

This Perl implementation is modelled on the \s-1PHP\s0 interface that can be found here:

<http://recaptcha.net/plugins/php/>

To use reCAPTCHA you need to register your site here:

<https://www.google.com/recaptcha/admin/create>

INTERFACE

Create a new \*(C`Captcha::reCAPTCHA\*(C'. Generates \s-1HTML\s0 to display the captcha. print $captcha->get_html( $PUB, $err );

Your reCAPTCHA public key, from the \s-1API\s0 Signup Page Optional. If set this should be either a string containing a reCAPTCHA status code or a result hash as returned by \*(C`check_answer\*(C'. Optional. Should the SSL-based \s-1API\s0 be used? If you are displaying a page to the user over \s-1SSL\s0, be sure to set this to true so an error dialog doesn't come up in the user's browser. Optional. A reference to a hash of options for the captcha. See \*(C`get_options_setter\*(C' for more details.

Returns a string containing the \s-1HTML\s0 that should be used to display the captcha.

You can optionally customize the look of the reCAPTCHA widget with some JavaScript settings. \*(C`get_options_setter\*(C' returns a block of Javascript wrapped in <script> .. </script> tags that will set the options to be used by the widget. $options is a reference to a hash that may contain the following keys:

Defines which theme to use for reCAPTCHA. Possible values are 'red', 'white' or 'blackglass'. The default is 'red'. Sets a tabindex for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user. Default: 0.

After the user has filled out the \s-1HTML\s0 form, including their answer for the \s-1CAPTCHA\s0, use \*(C`check_answer\*(C' to check their answer when they submit the form. The user's answer will be in two form fields, recaptcha_challenge_field and recaptcha_response_field. The reCAPTCHA library will make an \s-1HTTP\s0 request to the reCAPTCHA server and verify the user's answer.

Your reCAPTCHA private key, from the \s-1API\s0 Signup Page. The user's \s-1IP\s0 address, in the format 192.168.0.1. The value of the form field recaptcha_challenge_field The value of the form field recaptcha_response_field.

Returns a reference to a hash containing two fields: \*(C`is_valid\*(C' and \*(C`error\*(C'. my $result = $c->check_answer( 'your private key here', $ENV{'REMOTE_ADDR'}, $challenge, $response );

if ( $result->{is_valid} ) { print "Yes!"; } else { # Error $error = $result->{error}; } See the /examples subdirectory for examples of how to call \*(C`check_answer\*(C'. Note: this method will make an \s-1HTTP\s0 request to Google to verify the user input. If this request must be routed via a proxy in your environment, use the standard environment variable to specify the proxy address, e.g.: $ENV{http_proxy} = 'http://myproxy:3128';

CONFIGURATION AND ENVIRONMENT

Captcha::reCAPTCHA requires no configuration files or environment variables.

To use reCAPTCHA sign up for a key pair here:

<https://www.google.com/recaptcha/admin/create>

DEPENDENCIES

LWP::UserAgent, HTML::Tiny

INCOMPATIBILITIES

None reported .

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to \*(C`[email protected]\*(C', or through the web interface at <http://rt.cpan.org>.

AUTHOR

Andy Armstrong \*(C`<[email protected]>\*(C'

LICENCE AND COPYRIGHT

Copyright (c) 2007, Andy Armstrong \*(C`<[email protected]>\*(C'. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0 \s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0 \s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0 \s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0 \s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0 \s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0 \s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0 \s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1PROVE\s0 \s-1DEFECTIVE\s0, \s-1YOU\s0 \s-1ASSUME\s0 \s-1THE\s0 \s-1COST\s0 \s-1OF\s0 \s-1ALL\s0 \s-1NECESSARY\s0 \s-1SERVICING\s0, \s-1REPAIR\s0, \s-1OR\s0 \s-1CORRECTION\s0.

\s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1UNLESS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