#!/usr/local/bin/perl -w use strict; use Net::Blogger; my %cat_name = ( 1 => 'Linux-Mag', 2 => 'MySQL', 3 => 'Random', 4 => 'Personal', 5 => 'Windows', 6 => 'Macintosh', 7 => 'Perl', 8 => 'PHP', 9 => 'Yahoo', 10 => 'Soaring', 11 => 'Java', ); my $debug = 0; my %cat_id = reverse %cat_name; my $file = shift or die "usage: $0 \n"; my $blog_id = shift || 1; open F, "<$file" or die "can't open $file: $!"; my $title = ; chomp $title; my $cat_tmp = ; chomp $cat_tmp; my $cat_id; my $cat_name; if ($cat_tmp =~ /^\d+$/) { $cat_id = $cat_tmp; $cat_name = $cat_name{$cat_id}; } else { $cat_name = $cat_tmp; $cat_id = $cat_id{$cat_name}; } die "unknown category [$cat_tmp]" unless $cat_id and $cat_name; my $blank = ; my $body; { local($/) = undef; $body = ; } if ($debug) { print "Title: $title\n"; print "Category: $cat_name ($cat_id)\n"; print "[ start body ]\n"; print "$body"; print "[ end body ]\n"; } close F; my $mt = Net::Blogger->new(engine => 'movabletype'); $mt->Proxy('http://jeremy.zawodny.com/mt/mt-xmlrpc.cgi'); $mt->Username("jzawodn"); $mt->Password("******"); $mt->BlogId($blog_id); my $id = $mt->metaWeblog()->newPost( title => $title, description => $body, publish => 1 ) or die $mt->LastError(); $mt->mt()->setPostCategories( postid => $id, categories => [{categoryId => $cat_id}] ) or die $mt->LastError(); # "edit" the post with no changes so that our category change # activates. $mt->metaWeblog()->editPost( title => $title, description => $body, postid => $id, publish => 1 ); exit; __END__