Fetch a Blogger Atom Feed Which Requires Authorization

# This ruby script will retrieve a Blogger Atom feed which is for members only
# see http://wiki.derelik.net/ruby:google_calendar_api_example
require 'net/https'

blog_url = ARGV[0]
email = ARGV[1]
password = ARGV[2]

post_data = {"accountType"  => "GOOGLE",
"Email"  => email,
"Passwd"  => password,
"service"  => "blogger",
"source"  => "401_workaround_for_blogger_feeds"}

# Map the data to a string
post_data = (post_data.map {|k,v| k+"="+v}).join("&")

http = Net::HTTP.new("www.google.com",443)

http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.request_post("/accounts/ClientLogin", post_data,
  {
  'content-type' => 'application/x-www-form-urlencoded',
  'content-length' => post_data.length.to_s
  }
)

authhash = Hash[*response.body.split(/\n|=/)]

# Now that we have authentication get the Feed
http = Net::HTTP.new(blog_url)

response = http.request_get("/feeds/posts/default",
  {
    'Authorization' => "GoogleLogin auth=#{authhash['Auth']}",
    'Content-type' => 'application/atom+xml'
  }
)

puts response.body