reCAPTCHA Mailhide

reCAPTCHA Mailhide – getting started with the Mailhide functionality of Services_ReCaptcha

Instanciating the Services_ReCaptcha_MailHide class

To instanciate the Services_ReCaptcha_MailHide class just do:

<?php

require_once 'Services/ReCaptcha/MailHide.php';

$recaptcha = new Services_ReCaptcha_MailHide('your_public_key''your_private_key''email_to_hide@example.com');

?>

You can also pass an array of option as third parameter, or pass options later with the Services_ReCaptcha_Base::setOption() or Services_ReCaptcha_Base::setOptions()

Available options are:

Services_ReCaptcha_MailHide options
Name Description Type Default value
mask_text The chars that will be displayed in the email address to hide it string ... (three dots)
link_text An alternate string for the text of the link string null
link_title Text to display as the title (tooltip) of the link string Reveal this e-mail address
popup_width The popup width in pixels integer 500
popup_height The popup height in pixels integer 300

Recaptcha Mailhide example

<?php

/**
 * Include the Services_ReCaptcha_MailHide class
 */
require_once 'Services/ReCaptcha/MailHide.php';

// you must generate your API keys here:
// http://mailhide.recaptcha.net/apikey
$publicKey  'your_public_key';
$privateKey 'your_private_key';

// we instanciate our Services_ReCaptcha_MailHide instance with the public key
// and the private key
$mailhide1 = new Services_ReCaptcha_MailHide(
    
$publicKey,
    
$privateKey,
    
'johndoe@example.com'
);

$mailhide2 = new Services_ReCaptcha_MailHide(
    
$publicKey,
    
$privateKey,
    
'johndoe@example.com',
    array(
'link_text' => 'John Doe')
);

$mailhide3 = new Services_ReCaptcha_MailHide(
    
$publicKey,
    
$privateKey,
    
'johndoe@example.com'
);
$mailhide3->setOptions(
    array(
        
'link_text'    => 'Click here to display my email',
        
'link_title'   => 'Some help message',
        
'link_title'   => 'Some help message',
        
'popup_width'  => 800,
        
'popup_height' => 600,
    )
);

?>
<html>
<head>
    <title>recaptcha test</title>
</head>
<body>
    <h2>Hidden emails can be displayed like this:</h2>
    <p><?php echo $mailhide1 ?></p>
    <h2>Like this:</h2>
    <p><?php echo $mailhide2 ?></p>
    <h2>And even like this:</h2>
    <p><?php echo $mailhide3 ?></p>
</body>
</html>