the science and tech blog

May 12, 2008

My Perl module - Twitter Badge

Filed under: free, general, open source, perl, programming — Arul John @ 10:59 am
Tags: , , , ,

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 [code]

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.

5 Comments »

  1. Looks nifty, :) good job

    Comment by mozey — May 12, 2008 @ 12:36 pm

  2. A visual might be good.

    Its basically a widget that displays the Twitter updates on a webpage or a blog, right?

    Comment by Chittaranjan — May 12, 2008 @ 12:37 pm

  3. Hi YCR, I have a couple of screenshots on how to use the module. And yes, it can be used for display either on the command line or in a webpage.

    Comment by Arul John — May 13, 2008 @ 2:17 pm

  4. Thanks mozey.

    Comment by Arul John — May 13, 2008 @ 2:17 pm

  5. Somehow i missed the point. Probably lost in translation :) Anyway … nice blog to visit.

    cheers, Watchman!

    Comment by Watchman — June 19, 2008 @ 8:50 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.