1

我正在尝试向rails上的google方向api发送请求,我尝试了一些事情,这就是我现在所拥有的 -

 url = URI.parse(requested_url)
 full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}"
 the_request = Net::HTTP::Get.new(full_path)
 the_response = Net::HTTP.start(url.host, url.port) { |http| http.request(the_request) }
 raise "Response was not 200, response was #{the_response.code}" if the_response.code !=   "200"
 return the_response.body

但它提高了一个=错误的URI(不是URI?):http ://maps.googleapis.com/maps/api/directions/json? origin='תלאביב'&destination='ירושלים'&sensor=false

如果您将其粘贴到浏览器上,它会返回 ok。

4

0 回答 0