Module: WickyKuaidi100

Defined in:
lib/wicky_kuaidi100.rb,
lib/wicky_kuaidi100/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.connection(id, nu, com) ⇒ Object

Your code goes here…



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wicky_kuaidi100.rb', line 5

def self.connection(id, nu, com)

	url = URI.parse('http://api.kuaidi100.com/api')

	Net::HTTP.start(url.host, url.port) do |http|
req = Net::HTTP::Post.new(url.path)
req.set_form_data({
					id:"#{id}",
		 			com:"#{com}",
		 			nu:"#{nu}",
		 			valicode:"",
		 			show:"2",
		 			muti:"1",
		 			order:"desc"
				})

puts http.request(req).body

@content = http.request(req).body.force_encoding("UTF-8")
puts @content
	end
end