NAME

Captcha::reCAPTCHA::V2 - A Perl implementation of reCAPTCHA API version 2

VERSION

version 0.3

SYNOPSIS

Captcha::reCAPTCHA::V2 enables you to integrate reCAPTCHA version 2 into your web application.

use Captcha::reCAPTCHA::V2;

# Create a new instance of Captcha::reCAPTCHA::V2
my $rc = Captcha::reCAPTCHA::V2->new;

# Get HTML code to display the reCAPTCHA
my $rc_html = $rc->html('site key');

# Verify user's response
my $result = $rc->verify('secret', $response);

if ($result->{success}){
    # Good
} else {
    # Bad -- get first error that was returned
    $error = $result->{error_codes}->[0];
}

METHODS

new

Creates a new instance of Captcha::reCAPTCHA::V2.

my $rc = Captcha::reCAPTCHA::V2->new;

html

Returns the HTML code for rendering the reCAPTCHA widget.

my $html = $rc->html('site key', { theme => 'dark' });

Parameters:

  • $sitekey

    (Required) The site's public key provided by API

  • $options

    A reference to a hash of options that affect the appearance and behavior of the reCAPTCHA widget. Available options:

    • theme

      The color theme of the widget. Possible values are 'dark' and 'light'.

    • type

      The type of the captcha to serve. Possible values are 'audio' and 'image'.

    • size

      The size of the widget. Possible values are 'compact' and 'normal'.

See also: grecaptcha.render parameters.

verify

Verifies the user's response.

my $result = $rc->verify('secret', $response);

if ($result->{success}) {
    # ...
}

Parameters:

  • $secret

    (Required) The site's secret key provided by API

  • $response

    (Required) Response string retrieved from the submitted form field g-recaptcha-response.

  • $remoteip

    IP address of the user.

Returns a reference to a hash containing two fields: success and error_codes.

SEE ALSO

* Captcha::reCAPTCHA

* Google reCAPTCHA API Reference

ACKNOWLEDGEMENTS

Based on Andy Armstrong's a perl implementation of the reCAPTCHA API version 1 (Captcha::reCAPTCHA).

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/Sidnet/p5-Captcha-reCAPTCHA-V2/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/Sidnet/p5-Captcha-reCAPTCHA-V2

git clone https://github.com/Sidnet/p5-Captcha-reCAPTCHA-V2.git

AUTHOR

Pattawan Kaewduangdee <pattawan@cpan.org>

CONTRIBUTOR

Michal Wojciechowski <odyniec@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Pattawan Kaewduangdee.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.