otsune's SnakeOil RSSフィード

python -c "print''.join([chr(x) for x in 111&1101,110+~-~11,10^11*11,110+~-~11,-~101,-~11^11*11,~-110,111&11*11,11+11+10,11|~-0110,1-~11^11*11,10^11*11,-~11^11*11,110,101])"

2010-09-08

PlaggerのPublish::TwitterをOAuth対応に

PlaggerのPublish::TwitterをOAuth対応に - otsune's SnakeOil  を含むブックマーク はてなブックマーク - PlaggerのPublish::TwitterをOAuth対応に - otsune's SnakeOil  PlaggerのPublish::TwitterをOAuth対応に - otsune's SnakeOil  のブックマークコメント

既に誰かがやっている気もしなくも無いが

--- Plugin/Publish/Twitter.pm  2010-07-03 00:26:00.000000000 +0900
+++ Plugin/Publish/Twitter.pm  2010-09-08 03:18:25.000000000 +0900
@@ -18,34 +18,32 @@
 sub initialize {
     my($self, $context) = @_;
     my %opt = (
+        traits   => ['API::REST', 'OAuth'],
         username => $self->conf->{username},
         password => $self->conf->{password},
     );
-    for my $key (qw/ apihost apiurl apirealm/) {
+    for my $key (qw/apihost apiurl apirealm consumer_key consumer_secret/) {
         $opt{$key} = $self->conf->{$key} if $self->conf->{$key};
     }
-    $self->{twitter} = Net::Twitter->new(%opt);
+    my $nettwitter = Net::Twitter->new(%opt);
+    if ($self->conf->{access_token} and $self->conf->{access_token_secret}) {
+        $nettwitter->access_token($self->conf->{access_token});
+        $nettwitter->access_token_secret($self->conf->{access_token_secret});
+    }
+    $self->{twitter} = $nettwitter;
 }

サンプルのconfig.yaml抜粋

  - module: Publish::Twitter
    config:
      username: dankogai
#      password: base64::a29nYWlkYW4= 
      consumer_key: ***
      consumer_secret: ***
      access_token: ***
      access_token_secret: ***
      templatize: 1
      maxlength: 139

参考url http://d.hatena.ne.jp/layerzero/20090930/p1

トラックバック - http://subtech.g.hatena.ne.jp/otsune/20100908