* from http://d.hatena.ne.jp/layerzero/20090930/p1 twitter-0.1@44
authormitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 11 Sep 2010 02:07:55 +0000 (02:07 +0000)
committermitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sat, 11 Sep 2010 02:07:55 +0000 (02:07 +0000)
   * get_oauth.pl
   * nt_bot.pl
 * from http://www.otchy.net/20090629/making-of-twitter-bot-1/
   * twitbot.pl

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

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

diff --git a/get_oauth.pl b/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/nt_bot.pl b/nt_bot.pl
new file mode 100755 (executable)
index 0000000..3fec52e
--- /dev/null
+++ b/nt_bot.pl
@@ -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/twitbot.pl b/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 を更新するテストですよー');