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:
new(%args)
Twitter::Badge
KEY DEFAULT VALUE =========== ============= id undef screen_name undef ua Mozilla/4.0
id
[OPTIONAL] This parameter is the Twitter ID, a number that is associated with the Twitter screen name.
screen_name
[OPTIONAL] This parameter is the Twitter screen name.
ua
[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:
fetch()
name
text
profile_image_url
followers_count
created_at
The method screen_name() returns the screen_name value. If a parameter is passed into it, screen_name is set to that value.
screen_name()
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/
ua()
The method name() returns the name value retrieved from the account specified by the Twitter ID.
name()
The method text() returns the text value retrieved from the account specified by the Twitter ID.
text()
The method profile_image_url() returns the profile_image_url value retrieved from the account specified by the Twitter ID
profile_image_url()
The method followers_count() returns the followers_count value retrieved from the account specified by the Twitter ID.
followers_count()
The method created_at() returns the created_at value - the time the user updated his/her Twitter status.
created_at()
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.
$twitter
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.
bug-twitter-badge at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Twitter::Badge
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Twitter-Badge
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Twitter-Badge
CPAN Ratings
http://cpanratings.perl.org/d/Twitter-Badge
Search CPAN
http://search.cpan.org/dist/Twitter-Badge/
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.
To install Twitter::Badge, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Twitter::Badge
CPAN shell
perl -MCPAN -e shell install Twitter::Badge
For more information on module installation, please visit the detailed CPAN module installation guide.