Del.icio.us to Wordpress

I’ve just uploaded a new project on Github called delicious_wp: it’s a small Ruby script that simply fetches the items stored in del.icio.us the previous week and creates a blog post with them. You can set up a small cron job to execute this script every week, which is what I’ve done for this blog :) I know del.icio.us has a similar feature integrated, but it executes daily, instead of weekly, which is what I wanted.

To use it, just clone the repository, copy the config.yaml.sample file as config.yaml and edit its values inside. Run the script and voilĂ ! A new blog post entry with your del.icio.us bookmarks.

The script can also be helpful to those wondering how to use the XML-RPC interface of WordPress from a Ruby script, or how to use the Net::HTTP library to consume a REST API.

def get_delicious_bookmarks
  # Connect to delicious and get updates
  http = Net::HTTP.new(DELICIOUS_SERVER, DELICIOUS_PORT)
  http.use_ssl = true
  req = Net::HTTP::Get.new(DELICIOUS_DATES_PATH)
  req.add_field("User-Agent", DELICIOUS_USER_AGENT)
  req.basic_auth username, password
  response = http.request(req)
  results = response.body
def post_to_wordpress(title, text)
  entry = {
    :title => title,
    :description => text
  }
  # Connect to Wordpress using the XML-RPC interface
  blog = XMLRPC::Client.new(server, path, port)
  blog.call("metaWeblog.newPost", blogid, username,
                            password, entry, true)

Enjoy! As usual, the code is released with a BSD license.