Captcha::reCAPTCHA::V2 - A Perl implementation of reCAPTCHA API version 2
version 0.3
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];
}
Creates a new instance of Captcha::reCAPTCHA::V2.
my $rc = Captcha::reCAPTCHA::V2->new;
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.
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
.
* Google reCAPTCHA API Reference
Based on Andy Armstrong's a perl implementation of the reCAPTCHA API version 1 (Captcha::reCAPTCHA).
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.
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
Pattawan Kaewduangdee <[email protected]>
Michal Wojciechowski <[email protected]>
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.