I’m trying to use Curb (curb.rubyforge.org) to call a RESTful API that needs parameters supplied in a get request.
I want to fetch a URL like http://foo.com/bar.xml?bla=blablabla. I’d like to be able to do something like
Curl::Easy.perform("http://foo.com/bar.xml", :bla => 'blablabla') {|curl|
curl.set_some_headers_if_necessary
}
but so far, the only way I can see to do this is by manually including the ?bla=blablabla in the URL and doing the encoding myself. Surely there is a right way to do this, but I can’t figure it out reading the documentation.
If you don’t mind using ActiveSupport ‘~> 3.0’, there’s an easy workaround –
to_querymethod, which converts hash to query string ready to be used in URL.