Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Net::Twitter's RetryOnError

  • Loading branch information...
commit d59b8c2a7eed51324d7ed65a2078a3ec08aae236 1 parent c1dd458
@acme authored
Showing with 9 additions and 17 deletions.
  1. +1 −0  CHANGES
  2. +1 −1  bin/twimap
  3. +7 −16 lib/App/Twimap.pm
View
1  CHANGES
@@ -6,6 +6,7 @@ Revision history for Perl module App::Twimap:
- handle replies to private/deleted tweets
- add a plain text version (with multipart/alternative)
- move to using the _str JSON entries for IDs
+ - try and go as fast as we can, given Twitter's rate limiting
0.01 Wed Sep 14 11:19:03 BST 2011
- initial release
View
2  bin/twimap
@@ -8,7 +8,7 @@ use Net::Twitter;
my $config = Config::Tiny->read( shift || 'twimap.conf' );
$config->{imap}->{Uid} = 1;
-$config->{twitter}->{traits} = [qw/OAuth API::REST RateLimit/];
+$config->{twitter}->{traits} = [qw/OAuth API::REST RateLimit RetryOnError/];
my $mailbox = $config->{_}->{mailbox} || die "No mailbox";
View
23 lib/App/Twimap.pm
@@ -50,23 +50,14 @@ sub sync_home_timeline {
while (1) {
warn
"Fetching home timeline since id $since_id and max_id $max_id...";
- my $tweets;
my $new_tweets = 0;
- while (1) {
- my $conf = {
- count => 100,
- include_entities => 1
- };
- $conf->{since_id} = $since_id if $since_id;
- $conf->{max_id} = $max_id if $max_id;
- eval {
- $tweets = $twitter->home_timeline($conf);
- warn Dumper( $twitter->get_error ) unless $tweets;
- };
- last unless $@;
- warn $@;
- sleep 10;
- }
+ my $conf = {
+ count => 100,
+ include_entities => 1,
+ };
+ $conf->{since_id} = $since_id if $since_id;
+ $conf->{max_id} = $max_id if $max_id;
+ my $tweets = $twitter->home_timeline($conf);
foreach my $data (@$tweets) {
my $tweet = App::Twimap::Tweet->new( data => $data );
Please sign in to comment.
Something went wrong with that request. Please try again.