Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (12 sloc) 497 Bytes
require "net/http"
require "uri"
uri = URI.parse("http://example.com/search")
# Shortcut
response = Net::HTTP.post_form(uri, {"q" => "My query", "per_page" => "50"})
# Full control
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"q" => "My query", "per_page" => "50"})
# Tweak headers, removing this will default to application/x-www-form-urlencoded
request["Content-Type"] = "application/json"
response = http.request(request)