
Twitter::Badge - Perl module that displays the current Twitter information of a user

Version 0.03

use Twitter::Badge; # If you know the Twitter ID my $id = 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"; # display status print $twitter->name.' has '.$twitter->followers_count." followers\n"; # display followers # .. and so on

Twitter::Badge is a class that retrieves the Twitter information for the user's ID or screen name.

The method new(%args) creates and returns a new Twitter::Badge object. It takes either zero parameters or a hash containing at least one of the following:
KEY DEFAULT VALUE
=========== =============
id undef
screen_name undef
ua Mozilla/4.0
[OPTIONAL] This parameter is the Twitter ID, a number that is associated with the Twitter screen name.
[OPTIONAL] This parameter is the Twitter screen name.
[OPTIONAL] This parameter is the User-Agent string that is included in the request to Twitter. You can find a list of user-agent strings at http://aruljohn.com/ua/
The method fetch() fetches the following information from the user's corresponding Twitter account:
The method screen_name() returns the screen_name value. If a parameter is passed into it, screen_name is set to that value.
This print the current Twitter screen name. print $twitter->screen_name
This will set the current Twitter screen name to 'aruljohn'. $twitter->screen_name('aruljohn');
The method ua() returns the User-Agent string value. If a parameter is passed into it, ua is set to that value. You can find a list of User-Agent strings at http://aruljohn.com/ua/
The method name() returns the name value retrieved from the account specified by the Twitter ID.
The method text() returns the text value retrieved from the account specified by the Twitter ID.
The method profile_image_url() returns the profile_image_url value retrieved from the account specified by the Twitter ID
The method followers_count() returns the followers_count value retrieved from the account specified by the Twitter ID.
The method created_at() returns the created_at value - the time the user updated his/her Twitter status.

use Twitter::Badge; my $twitter = Twitter::Badge->new(); # create an empty Twitter::Badge object # Setting Twitter ID $twitter->id(14512139); # setting ID to 14512139 $twitter->fetch(); # fetch Twitter info [with that Twitter ID] print $twitter->name.' says: '.$twitter->text."\n"; print $twitter->name.' posted on '.$twitter->created_at."\n";
use Twitter::Badge; # Create object with screen name $twitter = Twitter::Badge->new(screen_name => 'justjul'); # create the object $twitter->fetch(); print $twitter->name.' says: '.$twitter->text."\n"; print $twitter->name.' posted on '.$twitter->created_at."\n";
use Twitter::Badge;
# Create object with User-Agent
$twitter = Twitter::Badge->new(ua => 'Mozilla/6.0 (Twitterbot)'); # create the object
$twitter->screen_name('aruljohn');
$twitter->fetch();
print $twitter->name.' says: '.$twitter->text."\n";
print $twitter->name.' posted on '.$twitter->created_at."\n\n";
# Change screen name
$twitter->screen_name('justjul');
$twitter->fetch();
print $twitter->name.' says: '.$twitter->text."\n" if defined $twitter->text;
print $twitter->name.' posted on '.$twitter->created_at."\n" if defined $twitter->created_at;
print $twitter->name.' has '.$twitter->followers_count." followers\n\n" if defined $twitter->followers_count;
You can use the Data::Dumper module to check the contents of $twitter at any time.
use Data::Dumper; # other code goes here print Dumper($twitter);

Arul John - http://aruljohn.com/

Please report any bugs or feature requests to bug-twitter-badge at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Twitter-Badge. 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 Twitter::Badge
You can also look for information at:


Copyright 2008-2012 Arul John.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.