* making twitter client by Perl
authormitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 11 Sep 2010 02:09:19 +0000 (02:09 +0000)
committermitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 11 Sep 2010 02:09:19 +0000 (02:09 +0000)
 * copy vendor drop to trunk

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@45 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

twitter/get_oauth.pl [new file with mode: 0755]
twitter/nt_bot.pl [new file with mode: 0755]
twitter/twitbot.pl [new file with mode: 0755]

diff --git a/twitter/get_oauth.pl b/twitter/get_oauth.pl
new file mode 100755 (executable)
index 0000000..6f840ab
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use utf8;
+use Net::Twitter;
+
+my $consumer_key = 'CONSUMER_KEY';
+my $consumer_key_secret = 'CONSUMER_KEY_SECRET';
+
+my $nt = Net::Twitter->new(
+  traits          => ['API::REST', 'OAuth'],
+  consumer_key    => $consumer_key,
+  consumer_secret => $consumer_key_secret,
+);
+print 'access this url by bot account : '.$nt->get_authorization_url."\n";
+print 'input verifier PIN : ';
+my $verifier = <STDIN>;
+chomp $verifier;
+
+my $token = $nt->request_token;
+my $token_secret = $nt->request_token_secret;
+
+$nt->request_token($token);
+$nt->request_token_secret($token_secret);
+
+my($at, $ats) = $nt->request_access_token(verifier => $verifier);
+
+print "Access token : ".$at."\n";
+print "Access token secret : ".$ats."\n";
diff --git a/twitter/nt_bot.pl b/twitter/nt_bot.pl
new file mode 100755 (executable)
index 0000000..3fec52e
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use utf8;
+use Net::Twitter;
+
+my $consumer_key = 'CONSUMER_KEY';
+my $consumer_key_secret = 'CONSUMER_KEY_SECRET';
+my $access_token = 'ACCESS_TOKEN';
+my $access_token_secret = 'ACCESS_TOKEN_SECRET';
+
+my $nt = Net::Twitter->new(
+  traits          => ['API::REST', 'OAuth'],
+  consumer_key    => $consumer_key,
+  consumer_secret => $consumer_key_secret,
+);
+$nt->access_token($access_token);
+$nt->access_token_secret($access_token_secret);
+
+my $res = $nt->update({ status => "test tweet!" });
diff --git a/twitter/twitbot.pl b/twitter/twitbot.pl
new file mode 100755 (executable)
index 0000000..b53c6dc
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use YAML::Tiny;
+use Net::Twitter;
+
+my $config = (YAML::Tiny->read('config.yml'))->[0];
+my $twit = Net::Twitter->new(username => $config->{'username'}, password => $config->{'password'});
+
+$twit->update('Perl から Twiitter を更新するテストですよー');