Getting Google Image search to work within Rails

   I'm getting this strange behavior when I try to run search for
images using Google Images API. I suspect it's because of my code and
not the API itself, here's what I wrote:

    uri = URI.parse("")
    http =, uri.port)
    http.use_ssl = true
    path = "ajax/services/search/images?v=1.0&q=gatsby&key=<key>"
    path = URI.escape(path)
    response = http.get(path, {"HTTP_REFERER" => "<my website>", 'User-
Agent' => 'mozilla'})
    data = response.body
    result = JSON.parse(data)

I'm creating the HTTP object this way(with just the server, then
calling the GET on the path) because I wanted to set the use_ssl flag

The response I get is:

<HTML><HEAD><meta http-equiv="content-type" content="text/
<H1>302 Moved</H1>
The document has moved
<A HREF="">here</A>.

When I try to access the same URL using curl, it works perfectly and
returns a JSON object, so I know the data is not wrong. Any ideas?

Older discussions related to the Image search said that the URL was a
plain HTTP url, it seems to have been changed to use HTTPS recently.

Thanks in advance !