开发者

open url in ruby controller

I need to call some php script from ROR controller, so I tried to use open("url"), but it didn't work.

For example,

def successful_login
  open("http://stackoverflow.com")
  redirect_to home_url
end

Errno::EINVAL in UsersController#create

Invalid argument - ht开发者_运维问答tp://stackoverflow.com

Any idea?


require 'net/http'
Net::HTTP.get('www.example.com', '/index.html')

The API docs


require 'net/http' require 'uri'

url = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.start(url.host, url.port) {|http|
  http.get('/index.html')
}
puts res.body
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜