Drkcore

16 04 2009 perl Vox Tweet

Vox用のクライアント

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;

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021