Twitter/Wassr まとめて投稿

TwitterWassr に同じ内容の投稿をする為だけのスクリプト

#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode;
use Perl6::Say;

use Net::Twitter;
use Net::Wassr;
use Term::Encoding;

my $conf = {
    twit  => { user => 'username', passwd => 'password' },
    wassr => { user => 'username', passwd => 'password' },
};

my $comment = shift || die "$0 commnet";
$comment = decode(Term::Encoding::get_encoding, $comment);

my $result = Net::Wassr->new(
                user   => $conf->{wassr}{user},
                passwd => $conf->{wassr}{passwd},
             )->update( {source => 'Net::Wassr', status => $comment } );
if (! $result) {
    warn 'Net::Wassr update failed';
}
    
$result = Net::Twitter->new(
              username => $conf->{twit}{user},
              password => $conf->{twit}{passwd},
          )->update($comment);
if (! $result) {
    warn 'Net::Twitter update failed';
}


Net::TwitterCPAN からインストール出来るけど,Net::Wassr に関してはまだ CPAN に上がってないようなので,CodeRepos から check out してインストールしてやる必要があります。

svn co http://svn.coderepos.org/share/lang/perl/Net-Wassr/


Net::Wassr の update メソッドのエンコーディング処理を一部変更しました。

108c108
<     Encode::from_to( $args->{status}, $encode, 'utf8', 0 );
    • -
> Encode::encode($encode, $args->{status});


参考