Skip to content

Instantly share code, notes, and snippets.

@aki017
Created December 10, 2012 22:34
Show Gist options
  • Save aki017/4253963 to your computer and use it in GitHub Desktop.
Save aki017/4253963 to your computer and use it in GitHub Desktop.
DMでつぶやく奴
#! /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