uzullaがブログ

uzullaがブログです。

テスト

テストします

use Net::Twitter::Lite;
use Config::Pit;
use Data::Dumper;
use feature say;
use Date::Parse;
use DateTime;

# 読み出し
my $config = pit_get("twitter.com_oauth_uzulla_sandbox" , require => {
    "consumer_key" => "req", 
    "consumer_secret" => "req", 
    "ACCESS_TOKEN" => "req", 
    "ACCESS_TOKEN_SECRET" => "req", 
});
die 'pit_get failed.' if !%$config;
my $consumer_key    = $config->{consumer_key} or die 'consumer_key not found.';
my $consumer_secret = $config->{consumer_secret} or die 'consumer_securet not found.';
my $ACCESS_TOKEN = $config->{ACCESS_TOKEN} or die 'ACCESS_TOKEN not found.';
my $ACCESS_TOKEN_SECRET = $config->{ACCESS_TOKEN_SECRET} or die 'ACCESS_TOKEN_SECRET not found.';


my %CONSUMER_TOKENS = (
    consumer_key    => $consumer_key,
    consumer_secret => $consumer_secret,
);
my $t = Net::Twitter::Lite->new(%CONSUMER_TOKENS);
$t->access_token($ACCESS_TOKEN);
$t->access_token_secret($ACCESS_TOKEN_SECRET);


my $cursor = -1 ;
processFriendAll($cursor, \&printNameAndLastUpdate);


sub printNameAndLastUpdate{
	my($cursor, $func) = @_;
	
	my $friend_list =  eval { $friend_list = $t->friends({ cursor=>$cursor }) };
	$cursor = $friend_list->{next_cursor_str};	
	
	foreach my $friend (@{$friend_list->{users}}){
		&$func($friend);
	}
	
	if($cursor==0){
		return;
	}else{
		processFriendAll($cursor, $func);
	}
}

sub printNameAndLastUpdate{
	my ($friend) = @_;
	
	print $friend->{id}.":".$friend->{screen_name}. " ";
	if(!defined $friend->{status}){
		say 'status unknown';
		next;
	}else{
		my $created_at_time = str2time($friend->{status}->{created_at});
		$dt = DateTime->from_epoch(epoch => $created_at_time);
		say $dt->ymd('/');
	}	

}
SELECT * FROM user WHERE id=123 LIMIT 1;


ちょっとCSSはいじらないとつらいなー。
まあはてダよりまだ低機能なのがさびしいのと、SNS連携は早くほしいな。