Config::Pitとエディタが立ち上がるように変更した。
サービスのURIを知るためにwgetしたらつながらなくてあせったが--auth-no-challengeオプションを入れて解決
#!/opt/local/bin/perl
use XML::Atom::Client;
use XML::Atom::Entry;
use constant NS_DC => 'http://purl.org/dc/elements/1.1/';
use File::Temp;
use File::Slurp;
use Path::Class;
use Config::Pit;
my $vox = "kzfm.vox.com";
my $title = "";
my $content = "";
my $category = "life";
my $config = pit_get($vox, require => {
"username" => "your username on vox",
"password" => "your password on vox",
"postURI" => "your potURI"
});
my $f = File::Temp->new();
close $f;
my $t = file($f->filename)->stat->mtime;
system $ENV{EDITOR}, $f->filename;
if ($t == file($f->filename)->stat->mtime) {
print STDERR "No changes.";
} else {
my @lines = read_file($f->filename);
$title = shift @lines;
$content = join "", @lines
}
die "content not found\n" unless $content;
my $api = XML::Atom::Client->new;
$api->username($config->{username});
$api->password($config->{password});
my $entry = XML::Atom::Entry->new;
$entry->title($title);
$entry->content($content);
my @tags = split /,/, $category;
my $dc = XML::Atom::Namespace->new( dc => NS_DC );
foreach my $tag (@tags) {
$entry->add( $dc, 'subject', $tag);
}
my $EditURI = $api->createEntry($config->{postURI}, $entry);
print $api->errstr if $api->errstr;