Created
December 10, 2012 22:34
-
-
Save aki017/4253963 to your computer and use it in GitHub Desktop.
DMでつぶやく奴
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/perl | |
use Net::Twitter; | |
use strict; | |
use warnings; | |
use YAML; | |
use utf8; | |
my $setting = YAML::LoadFile("config.yaml"); | |
my $consumer_key = $setting->{"c"}; | |
my $consumer_secret = $setting->{"cs"}; | |
my $token = $setting->{"t"}; | |
my $token_secret = $setting->{"ts"}; | |
my $twit = Net::Twitter->new( | |
consumer_key => $consumer_key, | |
consumer_secret => $consumer_secret, | |
); | |
$twit->access_token ($token); | |
$twit->access_token_secret($token_secret); | |
my $dm = $twit->direct_messages({since_id=>$setting->{time}}); | |
# my $dm = $twit->direct_messages(); | |
for my $item(@$dm){ | |
eval{ $twit->update("$item->{text} [$item->{sender}->{name}]")}; | |
$setting->{"time"} = @$dm[0]->{id} if(defined(@$dm[0]->{id})); | |
} | |
YAML::DumpFile("config.yaml", $setting); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment