Hi,
   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("https://ajax.googleapis.com/";)
    http = Net::HTTP.new(uri.host, 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
explicitly.

The response I get is:

<HTML><HEAD><meta http-equiv="content-type" content="text/
html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com";>here</A>.
</BODY></HTML>

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 !

Sudarshan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to