Class: RWenking::Client
- Inherits:
-
Object
- Object
- RWenking::Client
- Defined in:
- lib/rwenking/client.rb
Instance Method Summary collapse
- #get_phish(id = nil) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #scan(options) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 |
# File 'lib/rwenking/client.rb', line 8 def initialize() return nil until @appname = [:appname] @key = [:appkey] end |
Instance Method Details
#get_phish(id = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rwenking/client.rb', line 22 def get_phish(id=nil) apiurl = "http://antiphishing.aliyun-inc.com/commonget" id ||= 0 response = RestClient.get(apiurl, {:params => {:appname => @appname, :id => id, :sign => sign(@key, id)}}) xml = Nokogiri::XML(response.body) xml.xpath("//item").map do |i| {'id' => i.xpath('url').attr('id').value ,'url' => i.xpath('url').inner_text, 'extradata' => i.xpath('extradata').inner_text} end end |
#scan(options) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rwenking/client.rb', line 14 def scan() apiurl = "http://antiphishing.aliyun-inc.com/commonrecv" url = CGI.escape([:url]) extra_data = [:extradata] response = RestClient.post(apiurl, {:sign => sign(@key, url), :appname => @appname, :url => url, :extradata => extra_data}) return response.body end |