My Perl module – Twitter Badge

I wrote my first Perl module Twitter::Badge sometime back and just released version 0.02 with a minor change.

This module provides you with the API required to check any Twitter’s status and other details. The general procedure is something like this:

1. Install the Perl module with CPAN (Linux, Unix, or Mac) or PPM (if you use Windows).

Using CPAN, you have to do this:

perl -MCPAN -e shell

install Twitter::Badge

If you want to do it in one line:

perl -MCPAN -e 'install Twitter::Badge'

You can also download the source, and build the module with:

perl Makefile.PL

make

make install

2. After installing Twitter::Badge, test if its running with a simple example.

use Twitter::Badge;

# Try it with my Twitter ID
my $id = shift || 14512139;                   # define the Twitter ID
my $twitter = Twitter::Badge->new(id => $id); # create the object for that ID
$twitter->fetch();                            # get information for this ID

# Display status
print $twitter->name.' says - '.$twitter->text."\n"
    if defined $twitter->text;            # display status
print $twitter->name.' has '.$twitter->followers_count." followers\n"
    if defined $twitter->followers_count; # display follower count

You can find the complete documentation here.

This module is very basic right now and subject to change whenever Twitter changes its XML output.

The latest version of Twitter::Badge is 0.02. You may use it at your own risk.

Let me know if you would like any features added in this module.

UPDATE: I have a couple of screenshots (following Chittaranjan’s post) to help newbies use this module.

Screenshot 1

Twitter badge code

Screenshot 2 [execution]

Twitter badge execution

It can be used in any Perl script, either executed on the command line or for the web.

If you're a Perl developer or have developed simple CGI scripts, this will be a piece of cake for you.

Advertisements