Curl on Ruby on Rails

前端 未结 3 1054
无人及你
无人及你 2020-12-15 22:05

how to use curl on ruby on rails? Like this one

curl -d \'params1[name]=name¶ms2[email]\' \'http://mydomain.com/file.json\'
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 22:56

    Here is a curl to ruby's net/http converter: https://jhawthorn.github.io/curl-to-ruby/

    For instance, a curl -v www.google.com command is equivalent in Ruby to:

    require 'net/http'
    require 'uri'
    
    uri = URI.parse("http://www.google.com")
    response = Net::HTTP.get_response(uri)
    
    # response.code
    # response.body
    

提交回复
热议问题