summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-06-29 14:57:47 +0100
committerdakkar <dakkar@thenautilus.net>2018-06-29 14:57:47 +0100
commit2ca0c78590a78a237669820ac225c378058d9b44 (patch)
treec5a1053fee334d6ff83860d66f8108368d2c676c
parentgiving up, just migrate the current set of people (diff)
downloadtweet-archive-migrate-to-Twitter-API.tar.gz
tweet-archive-migrate-to-Twitter-API.tar.bz2
tweet-archive-migrate-to-Twitter-API.zip
home_timeline worksmigrate-to-Twitter-API
no automatic cursor support yet, so friends/followers won't return the whole list
-rw-r--r--cpanfile4
-rw-r--r--lib/Dakkar/TweetArchive.pm29
-rw-r--r--lib/Dakkar/TweetArchive/Store.pm2
-rw-r--r--tweet-archive.pl4
4 files changed, 18 insertions, 21 deletions
diff --git a/cpanfile b/cpanfile
index 6a5df06..88cf774 100644
--- a/cpanfile
+++ b/cpanfile
@@ -8,7 +8,7 @@ requires 'experimental';
requires 'JSON::MaybeXS';
requires 'Moo';
requires 'Moo::Role';
-requires 'namespace::clean';
-requires 'Net::Twitter';
+requires 'namespace::autoclean';
+requires 'Twitter::API';
requires 'Path::Class';
requires 'Types::Standard';
diff --git a/lib/Dakkar/TweetArchive.pm b/lib/Dakkar/TweetArchive.pm
index 3c0d35e..f023359 100644
--- a/lib/Dakkar/TweetArchive.pm
+++ b/lib/Dakkar/TweetArchive.pm
@@ -2,9 +2,9 @@ package Dakkar::TweetArchive;
use 5.024;
use Moo;
use experimental 'signatures';
-use Net::Twitter;
+use Twitter::API;
use Types::Standard qw(Str InstanceOf);
-use namespace::clean;
+use namespace::autoclean;
has [qw(consumer_key consumer_secret access_token access_token_secret)] => (
is => 'ro',
@@ -14,27 +14,24 @@ has [qw(consumer_key consumer_secret access_token access_token_secret)] => (
has client => (
is => 'lazy',
- isa => InstanceOf['Net::Twitter'],
+ isa => InstanceOf['Twitter::API'],
);
sub _build_client($self) {
- my $nt = Net::Twitter->new(
- traits => [
- qw/API::RESTv1_1 OAuth RetryOnError/,
- AutoCursor => {
- max_calls => 16,
- force_cursor => 1,
- array_accessor => 'users',
- methods => [qw/friends followers/],
- },
- ],
+ my $nt = Twitter::API->new_with_traits(
+ traits => [qw{Enchilada RateLimiting}],
+ # AutoCursor => {
+ # max_calls => 16,
+ # force_cursor => 1,
+ # array_accessor => 'users',
+ # methods => [qw/friends followers/],
+ # },
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
+ access_token => $self->access_token,
+ access_token_secret => $self->access_token_secret,
);
- $nt->access_token($self->access_token);
- $nt->access_token_secret($self->access_token_secret);
-
return $nt;
}
diff --git a/lib/Dakkar/TweetArchive/Store.pm b/lib/Dakkar/TweetArchive/Store.pm
index cc64a87..ee6c9e4 100644
--- a/lib/Dakkar/TweetArchive/Store.pm
+++ b/lib/Dakkar/TweetArchive/Store.pm
@@ -7,7 +7,7 @@ use Types::Standard qw(Str InstanceOf);
use DateTime::Format::Strptime;
use DateTime::Format::Pg;
use JSON::MaybeXS;
-use namespace::clean;
+use namespace::autoclean;
has [qw(dsn user pass)] => (
is => 'ro',
diff --git a/tweet-archive.pl b/tweet-archive.pl
index 2424206..1882fc3 100644
--- a/tweet-archive.pl
+++ b/tweet-archive.pl
@@ -27,5 +27,5 @@ for my $tweet ($client->home_timeline($latest_id)->@*) {
$store->store_tweet($tweet);
}
-$store->store_friends($client->friends);
-$store->store_followers($client->followers);
+#$store->store_friends($client->friends);
+#$store->store_followers($client->followers);