Captcha::Peoplesign - Easily integrate Peoplesign CAPTCHA in your Perl application
use Captcha::Peoplesign; my $ps = Captcha::Peoplesign->new; # Output form print $ps->get_html({ ps_key => 'your_key', ps_location => 'your_location', ps_options => 'options_string', ps_sessionid=> 'challengeSessionID', ps_clientip => 'nnn.nnn.nnn.nnn', }); # Verify submission my $result = $ps->check_answer({ ps_key => 'your_key', ps_location => 'your_location', ps_sessionid=> $challengeSessionID, ps_responde => $challengeResponseString, }); if ( $result->{is_valid} ) { print "You're human!"; } else { # Error $error = $result->{error}; }
For some examples, please see the /examples subdirectory
Peoplesign is a clever CAPTCHA system which is quite a departure from the standard ones where you need to guess a difficult word.
To use Peoplesign you need to register your site here:
http://peoplesign.com
new
Arguments: \%args
Create a new Captcha::Peoplesign object.
Captcha::Peoplesign
html_mode
Sets what kind of HTML the library generates. Default is 'html', since we are going toward HTML5, but you can pass 'xml' if you use XHTML.
get_html( $pubkey, $error, $use_ssl, $options )
Generates HTML to display the captcha.
print $ps->get_html({ ps_key => 'your_key', ps_location => 'your_location', ps_clientip => 'client_ip_address', });
ps_key
Required.
Your Peoplesign key, from the API Signup Page on Peoplesign web site.
ps_location
Your Peoplesign location, from the API Signup Page on Peoplesign web site.
client_ip
The IP address of the client who is resolving the CAPTCHA.
ps_sessionid
Required when user doesn't pass the CAPTCHA.
The ps_sessionid is generated by Peoplesign and is used by it in order to recognize the user and display error messages. You should get it when the form is submitted in the challengeSessionID query parameter. If the test is not resolved succefully, you need to pass that session_id to get_html in order for a proper error message to be displayed to the user.
get_html
ps_options
Optional.
A string which allows to customize the Peoplesign widget. You can create it on Peopesign web site. I.e.:
language=english&useDispersedPics=false&numPanels=2&numSmallPhotos=6&useDragAndDrop=false&challengeType=pairThePhoto&category=(all)&hideResponseAreaWhenInactive=false
You can also pass an hashref, such as:
my $peoplesignOptions = { challengeType => "pairThePhoto", numPanels => "2", numSmallPhotos => "8", useDispersedPics => "false", smallPhotoAreaWidth => "" };
Returns a string containing the HTML that should be used to display the Peoplesign CAPTCHA widget.
check_answer
After the user has filled out the HTML form, use check_answer 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, which you need to pass to this method. The Peoplesign library will make an HTTP request to the Peoplesign server and verify the user's answer.
The value of the form field challengeSessionID.
ps_response
The value of the form field captcha_peoplesignCRS.
Returns a reference to a hash containing two fields: is_valid and error.
is_valid
error
my $result = $c->check_answer( ps_key => 'your_key', ps_location => 'your_location', ps_sessionid => $challengeSessionId, ps_response => $captcha_peoplesignCRS, ); if ( $result->{is_valid} ) { print "You're human!"; } else { # Error $error = $result->{error}; }
See the /examples subdirectory for examples of how to call check_answer.
To use Peoplesign sign up for a key here:
Michele Beltrame <mb@italpro.net>
<mb@italpro.net>
Heavily based on the original Peoplesign Perl library by David B. Newquist.
Some documentation and interface taken from Captch::reCAPTCHA module by Andy Armstrong.
Copyright (c) 2011 Michele Beltrame <mb@italpro.net>.
Copyright (c) 2008-2010 David B Newquist, Myricomp LLC
This module is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. See perlartistic.
To install Captcha::Peoplesign, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Captcha::Peoplesign
CPAN shell
perl -MCPAN -e shell install Captcha::Peoplesign
For more information on module installation, please visit the detailed CPAN module installation guide.