movable type の更新スクリプト。

今まで、いろいろとプログラムを書いてきたが、それを個人的に使うだけでは
もったいなく、思えてきたので公開。

まずは、movable type の更新スクリプト

require 'xmlrpc/client'
require 'uri'
require 'uconv'
require 'kconv'

class MT
def initialize username,passowrd,blogid
@url = 'http://cuzic.iobb.net/mt-xmlrpc.cgi'
@uri = URI.parse(@url)
@username = username
@password = password
@blogid = blogid
@server = XMLRPC::Client.new(@uri.host,@uri.path,@uri.port)
end

def newPost title,description,categoryId
title = Uconv.sjistou8(Kconv.tosjis(title))
description = Uconv.euctou8(description)
content = {"title" => title,
"description" => description,
"mt_convert_breaks" => 0,
}
postid = @server.call("metaWeblog.newPost",@blogid,@username,@password,content,1)
categories = [{"categoryId" => categoryId}]
@server.call("metaWeblog.setPostCategories",postid,@username,@password,categories)
end

def getRecentPosts
@server.call("metaWeblog.getRecentPosts",2,@username,@password,10)
end
end

ポイントは、もちろん、@server.call のところ。
ここをmovabletype のxmlrpcの説明を読んで応用してくれれば使える。