Created
June 27, 2010 01:39
-
-
Save dfreedm/454536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use JSON::DWIW; | |
| use LWP::Simple; | |
| my $json = JSON::DWIW->new; | |
| my $username = shift @ARGV; | |
| die "Need a username!\n" unless $username; | |
| my $twitter = | |
| "http://api.twitter.com/1/statuses/followers.json?screen_name=$username"; | |
| my $twitter_json = get_cursor(-1); | |
| while (1) { | |
| my $from_json = $json->from_json($twitter_json) | |
| or die | |
| "Got an empty string from twitter. Possibly protected account, or an error occured.\n"; | |
| my @followers = @{ $from_json->{users} }; | |
| for my $follower (@followers) { | |
| if ( $follower->{verified} ) { | |
| print $follower->{screen_name} . ' => ' . $follower->{name} . "\n"; | |
| } | |
| } | |
| last if $from_json->{next_cursor} == 0; | |
| $twitter_json = get_cursor( $from_json->{next_cursor} ); | |
| } | |
| sub get_cursor { | |
| my $cursor = shift; | |
| return get( $twitter . '&cursor=' . $cursor ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment