Consuming Our GeoRSS Feed With Ruby
GPS, Web 2.0, Code February 12th, 2008I’ve become a huge fan of Ruby over the past couple of years. In most cases development is much faster using Ruby scripting and Rails. I wanted to post a small example of code that demonstrates how to get GPS data out of the Ublip system via our GeoRSS feed.
The reasons for doing this are plentiful and I can think of a few here:
- A customer needs to automate the process of getting GPS data for their assets out of our system into theirs
- A web application, such as the JoeyTracker, needs to make a web service call to get data out our system into theirs
- A web developer needs to access our GeoRSS feed to build their own mapping feature into their website or blog
Since we implement HTTP basic auth this example will cover passing the proper credentials to our GeoRSS feed.
Here’s the code with a few comments:
device_id = 13 #Device ID in Ublip System
host = ‘customer.ublip.com’ #Personalized Customer URL
path = ‘/readings/last/’ + device_id.to_s #Path to GeoRSS feed
username = ‘username@domain.com’
password = ‘password’
http = Net::HTTP.new(host)
request = Net::HTTP::Get.new(path)
request.basic_auth(username, password)
response = http.request(request)
puts response.body #Display XML returned from GeoRSS feed
Pretty simple code, right? We specify the URL, username, password and then let Ruby’s built-in HTTP class take care of the rest.
Here’s the response from the server:

As you can see this is very similar to a traditional RSS feed, but with the proper GeoRSS encoding included. I won’t go into details about how to parse XML in Ruby, but here’s a great tutorial.


Recent Comments