This file contains 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/env perl | |
# top-followed-by-friends | |
# | |
# Prints a list of the users most followed by your friends, but not you. | |
# | |
# usage: top-followed-by-friends [twitter-screen_name-or-id] | |
# | |
# Throttles Twitter API calls so you don't get rate limited. | |
# Uses Cache::FileCache for storage. Set $cache_dir to something more | |
# permanent than /tmp if you want to keep the cache alive longer. |
This file contains 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/env perl | |
# unicode test | |
use strict; | |
use warnings; | |
use feature ':5.10'; | |
use Carp qw/confess/; | |
use Encode qw/decode_utf8/; | |
use Net::Twitter; |
This file contains 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/env perl | |
# module version report | |
use strict; | |
use warnings; | |
use Module::Versions::Report; | |
use Net::Twitter; | |
my $nt = Net::Twitter->new(legacy => 0, netrc => 1); | |
exit 0; |
This file contains 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/env perl | |
# unicode test | |
use strict; | |
use warnings; | |
use feature ':5.10'; | |
use Carp qw/confess/; | |
use Encode qw/decode_utf8/; | |
use Net::Twitter; | |
This file contains 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
my @friends; | |
for ( my $page = 1; 1; ++$page ) { | |
my $r = $nt->friends({ srceen_name => $screen_name, page => $page }); | |
last unless @$r; | |
push @friends, @$r; | |
} |
This file contains 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
my @friends; | |
for ( my $cursor = -1; $cursor; ) { | |
my $r = $nt->friends({ screen_name => $screen_name, cursor => $cursor }); | |
push @friends, @{$r->{users}}; | |
$cursor = $r->{next_cursor}; | |
} |
This file contains 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/env perl | |
# simple Twitter Search API example with object inlfation | |
use warnings; | |
use strict; | |
use Net::Twitter; | |
my $nt = Net::Twitter->new( | |
traits => ['API::Search', 'InflateObjects' ], | |
decode_html_entities => 1, | |
); |
This file contains 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/env perl | |
use warnings; | |
use strict; | |
use Net::Twitter; | |
my $nt = Net::Twitter->new(traits => ['API::Search'], decode_html_entities => 1); | |
my $r = $nt->search('perl net::twitter'); | |
for my $tweet ( @{$r->{results}} ) { |
This file contains 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
# to print the names of a user's lists with Net::Twitter | |
if ( my $r = $nt->list_lists($screen_name) ) { | |
for my $list ( @{$r->{lists}} ) { | |
print "$list->{name}\n"; | |
} | |
} |
This file contains 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
# Net::Twitter example - usіng cursors to get all list members | |
# Note: using traits => [qw/ API::Lists InflateObjects /] | |
my @members; | |
for ( my $cursor = -1; $cursor; ) { | |
my $r = $nt->list_members($user, $slug, { cursor => $cursor }); | |
print "got ", scalar @{$r->users}, "\n"; | |
push @members, @{$r->users}; | |
$cursor = $r->next_cursor; | |
} |