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 | |
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
#!/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
# 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; | |
} |
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
package Net::Twitter::Role::RateLimit; | |
use Moose::Role; | |
use namespace::autoclean; | |
requires qw/ua/; | |
has rate_remaining => ( isa => 'Int', is => 'rw', init_arg => undef, lazy => 1, | |
default => sub { shift->_ensure_rate('rate_remaining') } ); | |
has rate_reset => ( isa => 'Int', is => 'rw', init_arg => undef, lazy => 1, | |
default => sub { shift->_ensure_rate('rate_reset' ) } ); |
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
~/src/xmobar$ cabal install | |
Resolving dependencies... | |
Downloading action-permutations-0.0.0.0... | |
Configuring action-permutations-0.0.0.0... | |
Preprocessing library action-permutations-0.0.0.0... | |
Building action-permutations-0.0.0.0... | |
[1 of 1] Compiling Control.Applicative.Permutation ( Control/Applicative/Permutation.hs, dist/build/Control/Applicative/Permutation.o ) | |
/usr/bin/ar: creating dist/build/libHSaction-permutations-0.0.0.0.a | |
Installing library in | |
/home/mjm/.cabal/lib/action-permutations-0.0.0.0/ghc-6.10.4 |