#!/bin/env perl
use warnings;
use strict;
use File::Util;
use YAML::Syck;
use Perl6::Say;
use XMLRPC::Lite;
use Data::Dumper;
my $f = File::Util->new;
my @blogs = grep {/\.markdown$/} $f->list_dir('../_posts', '--recurse');
foreach (@blogs) {
my $yaml = LoadFile($_);
my $title = $yaml->{'title'};
my $text = $f->load_file("$_");
upload($title, $text);
};
sub upload {
my ($title, $text) = @_;
my $username = 'username';
my $password = 'password';
my $blogid = '123456';
my $proxyurl = 'http://blogname.blog.51cto.com/xmlrpc.php';
my $res = XMLRPC::Lite->proxy($proxyurl)->call('metaWeblog.newPost', $blogid, $username, $password, { title => "$title", description => "$text", categories => ['【创作类型:原创】','IT管理', ]}, 1)->result;
say "newPost id -- " . $res if $res;
};
目前还有几个问题: