1, 用Net::HTTP.get

uri = URI('http://xxxxxxx.com/api/user/1.0/json/get_info?&user_id=3')
Net::HTTP.get(uri)2, 用Net::HTTP.get 时加一些参数
uri = URI('http://xxxxxx.com/api/user/1.0/json/get_info')
params = { :user_id => 3}
uri.query = URI.encode_www_form(params)
res = Net::HTTP.get_response(uri)
puts res.body if res.is_a?(Net::HTTPSuccess)3, Net::HTTP.post_form
uri = URI('http://xxxxx.com/api/user/1.0/json/login')
res = Net::HTTP.post_form(uri, 'client_id' => '159d8a2f931514c107280', 'identity' => 'xxxxx002','password' => 'xxxxxx')
puts res.body4, res.methods里面有些很有用的方法
uri = URI('http://drhel31.sh.magima.com/api/user/1.0/json/get_info?&user_id=3')
res = Net::HTTP.get_response(uri)
# Headers
res.header # => "#"
res.read_header # => "#"
# Status 这个很有用,做接口调用成功与否的判断可用。
puts res.code # => '200'
puts res.message # => 'OK'
puts res.class.name # => 'HTTPOK'
res.code_type # => Net::HTTPOK
res.inspect # => "#"
# Body
puts res.body if res.msg == "OK" 5, 判断文件是否存在
File.exist? '/home/test/features/support/modul_login.rb'
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。