Atompub

http://d.hatena.ne.jp/keyword/%a4%cf%a4%c6%a4%ca%a5%c0%a5%a4%a5%a2%a5%ea%a1%bcAtomPub

require 'rubygems'
require 'atomutil'
require 'kconv'

module Atompub
  class HatenaClient < Client
    def publish_entry(uri)
      @hatena_publish = true
      update_resource(uri, ' ', Atom::MediaType::ENTRY.to_s)
    ensure
      @hatena_publish = false
    end

    private
    def set_common_info(req)
      req['X-Hatena-Publish'] = 1 if @hatena_publish
      super(req)
    end
  end
end


user = "myhoney0079"
pass = "xxxx"

auth = Atompub::Auth::Wsse.new(:username => user, :password => pass)
client = Atompub::HatenaClient.new(:auth => auth)
service = client.get_service 'http://d.hatena.ne.jp/%s/atom' % user
collection_uri = service.workspace.collections[1].href

entry = Atom::Entry.new(
  :title => 'My Entry Title',
  :updated => Time.now
)

entry.content = "テスト".toutf8

puts client.create_entry collection_uri, entry