The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Authenticated rss proxy

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andy Delcambre

Posts: 66
Nickname: adelcambre
Registered: Sep, 2007

Andy Delcambre is a developer at PLANET ARGON
Authenticated rss proxy Posted: Sep 4, 2007 11:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Andy Delcambre.
Original Post: Authenticated rss proxy
Feed Title: Andy Delcambre
Feed URL: http://feeds.feedburner.com/andydelcambre
Feed Description: Andy has been using Ruby and Ruby on Rails since 2006 and has been working with Ruby on Rails professionally since June 2007.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Andy Delcambre
Latest Posts From Andy Delcambre

Advertisement

At PLANET ARGON we use Basecamp for project tracking. Basecamp offers rss feeds of any new posts either globally or per project which is very handy for keeping track of things. The problem is that the rss feeds use http authentication which many feed readers (especially web based ones) don’t support. As a Google Reader user, I was out of luck.

After suffering through using email as my notification system, I decided to write a quick script to convert parameters to the url into http authentication. I initially considered doing this with cgi, but eventually decided to write a quick mongrel handler for the task. It actually turned out to be a lot easier than I thought it would be.

Here is the code:


require 'rubygems'
require 'mongrel'
require 'net/http'

HOSTNAME='your basecamp url'

class SimpleHandler < Mongrel::HttpHandler
  def process(request, response)
    params = {}
    request.params["QUERY_STRING"].split('&').each do |param|
      param = param.split('=')
      params[param[0]] = param[1]
    end
    response.start(200) do |head,out|
      head["Content-Type"] = "application/xml" 
      Net::HTTP.start(HOSTNAME) do |http|
        req = Net::HTTP::Get.new(params["url"])
        req.basic_auth params["user"], params["password"]
        response = http.request(req)
        out.write response.body
      end
    end
  end
end

h = Mongrel::HttpServer.new("0.0.0.0", "9898")
h.register("/feed", SimpleHandler.new)
h.run.join

It works really well, just run the script and point your feed reader at: http://hostname:9898/feed?user=<username>&password=<password>&url=<path of the rss feed>

for a normal global basecamp feed, it would look like: http://hostname:9898/feed?user=andy.delcambre&password=mypassword&url=/feed/recent_items_rss

Robby has confirmed that this works with open id basecamp logins as well.

This could be easily used with any authenticated rss feed you wanted. My goal was to make it general enough and easy enough for everyone at PLANET ARGON to use.

I had no idea it was so easy to add an http server to your script with mongrel. Zed Shaw is the man.

Read: Authenticated rss proxy

Topic: Agile RTP Tonight: Gradual Agile Previous Topic   Next Topic Topic: Ruby: Creating Custom Assertions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use