View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Nigel Horne > HTML-SocialMedia-0.25 > HTML::SocialMedia



Annotate this POD


Open  1
View/Report Bugs
Module Version: 0.25   Source   Latest Release: HTML-SocialMedia-0.27


HTML::SocialMedia - Put social media links into your website


Version 0.25


Many websites these days have links and buttons into social media sites. This module eases links into Twitter, Facebook and Google's PlusOne.

    use HTML::SocialMedia;
    my $sm = HTML::SocialMedia->new();
    # ...

The language of the text displayed will depend on the client's choice, making HTML::SocialMedia ideal for running on multilingual sites.

Takes optional parameter logger, an object which is used for warnings and traces. This logger object is an object that understands warn() and trace() messages, such as a Log::Log4perl object.

Takes optional parameter cache, an object which is used to cache country lookups. This cache object is an object that understands get() and set() messages, such as an CHI object.

Takes optional parameter, which is a CGI::Lingua object.



Creates a HTML::SocialMedia object.

    use HTML::SocialMedia;
    my $sm = HTML::SocialMedia->new(twitter => 'example');
    # ...

Optional parameters

twitter: twitter account name twitter_related: array of 2 elements - the name and description of a related account cache: This object will be an instantiation of a class that understands get and set, such as CHI. info: Object which understands host_name messages, such as CGI::Info.


Returns the HTML to be added to your website. HTML::SocialMedia uses CGI::Lingua to try to ensure that the text printed is in the language of the user.

    use HTML::SocialMedia;
    my $sm = HTML::SocialMedia->new(
        twitter => 'mytwittername',
        twotter_related => [ 'someonelikeme', 'another twitter feed' ]

    print "Content-type: text/html\n\n";

    print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
    print '<HTML><HEAD></HEAD><BODY>';

    print $sm->as_string(
        twitter_follow_button => 1,
        twitter_tweet_button => 1,
        facebook_like_button => 1,
        linkedin_share_button => 1,
        google_plusone => 1,
        reddit_button => 1,

    print '</BODY></HTML>';
    print "\n";

Optional parameters

twitter_follow_button: add a button to follow the account

twitter_tweet_button: add a button to tweet this page

facebook_like_button: add a Facebook like button

linkedin_share_button: add a LinkedIn share button

google_plusone: add a Google +1 button

reddit_button: add a Reddit button


Synonym for as_string.


Nigel Horne, <njh at>


When adding a FaceBook like button, you may find performance improves a lot if you use HTTP::Cache::Transparent.

Please report any bugs or feature requests to bug-html-socialmedia at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.



You can find documentation for this module with the perldoc command.

    perldoc HTML::SocialMedia

You can also look for information at:



Copyright 2011-2015 Nigel Horne.

This program is released under the following licence: GPL

syntax highlighting: