Class: QqHulian::Https

Inherits:
Object
  • Object
show all
Defined in:
lib/qq_hulian/https.rb

Instance Method Summary collapse

Instance Method Details

#https_get(url, args) ⇒ Object

https 请求 url 请求地址 args 需要传递的参数



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/qq_hulian/https.rb', line 15

def https_get(url,args)
  uri = URI.parse(url)
  uri.query = URI.encode_www_form(args)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Get.new(uri.request_uri)

  response = http.request(request)
  response.body
end

#https_post(url, args) ⇒ Object

https 请求 url 请求地址 args 需要传递的参数



31
32
33
34
35
36
37
38
39
40
# File 'lib/qq_hulian/https.rb', line 31

def https_post(url,args)
  uri = URI.parse(url)
  https=Net::HTTP.new(uri.host,uri.port)
  https.use_ssl=true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  req = Net::HTTP::Post.new(uri.path)
  req.set_form_data(args)
  res = https.request(req)
  res.body
end