15 October 2008
At tickex we have an simple API & quite a few clients using it. I've been a bit suprised by the number of programmers who have asked for sample code to access an XML API using HTTP get. So here is a simple example.
url = URI.parse('http://www.tickex.com/api/events')
user = your_user_id
pwd = your password
request = Net::HTTP::Get.new(url.path)
request.basic_auth(user, pwd)
response = Net::HTTP.new(url.host, url.port).start do |http|
http.request(request)
end
puts response.body

Trackback URL