13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/about_p/api.rb', line 13
def self.search(key, query)
client = Net::HTTP.new(BASE_URI, 443)
client.use_ssl = true
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
client.start do |http|
response = http.get("/users/search.json?query=#{URI.encode(query)}", {'X-AboutP-API-Key' => key})
case response.code.to_i
when 200
JSON.parse(response.body)
when 403
puts "403: Invalid API key"
exit 1
else
puts "#{response.code}: Something to wrong"
exit 1
end
end
end
|