tetsunosukeのnotebook

tetsunosukeのメモです

Twitterのみんなのステータスをとりあえず表示

#!/usr/bin/perl
use strict;
use CGI;
use Net::Twitter;
use YAML;
use Data::Dumper;
use Encode;

my $config = YAML::LoadFile('config.yaml');

my $cgi = new CGI;

print $cgi->header("text/html;charset=euc-jp");

print "<html><body>";


my $twitter = new Net::Twitter(
    'username' => $config->{twitter}->{userid},
    'password' => $config->{twitter}->{password}
) || die $!;


# get friends
my $friends = $twitter->friends;

foreach my $friend (@$friends){
    my $output = sprintf("%s:%s",
        $friend->{screen_name},
        encode('euc-jp', 
            decode('utf-8',
                   $friend->{status}->{text}
            )
        )
    );

    print $output,"<hr>";
        
}


print "</body></html>";
#YAML
twitter:
  userid: xxxxx
  password: xxxxx