I'm writing an app that uses the flickr api via http requests. I can't
figure out if the problem I'm having is the way I'm implementing this
with net/http or simply a problem with the flickr api. My code looks
like this:
xml_data = Net::HTTP.get_response(URI.parse(url)).body
Hpricot(xml_data)
I know the url is valid, because I can paste the url directly in to my
browser and I get valid xml from flickr. But when I issue this code in
my app, I get a blank response. xml_data is an empty string every time
and I can't figure out why. Am I requesting a response incorrectly?
Anyone have any idea?
-Kyle
···
--
Posted via http://www.ruby-forum.com/.
Anyone have any problems with receiving blank responses from a Net::HTTP
request but then get a valid response when issuing the request in a
browser?
···
--
Posted via http://www.ruby-forum.com/.
Kyle Peyton wrote:
I'm writing an app that uses the flickr api via http requests. I can't
figure out if the problem I'm having is the way I'm implementing this
with net/http or simply a problem with the flickr api. My code looks
like this:
xml_data = Net::HTTP.get_response(URI.parse(url)).body
Hpricot(xml_data)
I know the url is valid, because I can paste the url directly in to my
browser and I get valid xml from flickr. But when I issue this code in
my app, I get a blank response. xml_data is an empty string every time
and I can't figure out why. Am I requesting a response incorrectly?
Anyone have any idea?
Take a look at the HTTP response code (call .code instead of .body). If
it is in the 3xx range the server is redirecting you to a different URI.
A browser usually follows these redirects automatically.
-Matthias