projects
/
twirssi-net-twitter-lite.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
55ac82d
)
Update friend requests on Twitter (only) to support cursors instead of pages
author
Dan Boger
<zigdon@irc.peeron.com>
Thu, 22 Oct 2009 16:37:02 +0000
(09:37 -0700)
committer
Dan Boger
<zigdon@irc.peeron.com>
Thu, 22 Oct 2009 16:37:02 +0000
(09:37 -0700)
twirssi.pl
patch
|
blob
|
history
diff --git
a/twirssi.pl
b/twirssi.pl
index 15b64780fcd97816932f48550cab261f99a04cbe..0abb396b1756e7acf3371b3e4f880d68da3b89fe 100644
(file)
--- a/
twirssi.pl
+++ b/
twirssi.pl
@@
-792,18
+792,26
@@
sub cmd_upgrade {
sub load_friends {
my $fh = shift;
sub load_friends {
my $fh = shift;
+ my $cursor = -1;
my $page = 1;
my %new_friends;
eval {
my $page = 1;
my %new_friends;
eval {
- while (
1
)
+ while (
$page < 11 and $cursor ne "0"
)
{
print $fh "type:debug Loading friends page $page...\n"
if ( $fh and &debug );
{
print $fh "type:debug Loading friends page $page...\n"
if ( $fh and &debug );
- my $friends = $twit->friends( { page => $page } );
- last unless $friends;
+ my $friends;
+ if (ref $twit =~ /^Net::Twitter/) {
+ $friends = $twit->friends( { cursor => $cursor } );
+ last unless $friends;
+ $cursor = $friends->{next_cursor};
+ $friends = $friends->{users};
+ } else {
+ $friends = $twit->friends( { page => $page } );
+ last unless $friends;
+ }
$new_friends{ $_->{screen_name} } = time foreach @$friends;
$page++;
$new_friends{ $_->{screen_name} } = time foreach @$friends;
$page++;
- last if @$friends == 0 or $page == 10;
}
};
}
};