Class: AutoTagging::OpenCalais
- Inherits:
-
Object
- Object
- AutoTagging::OpenCalais
- Defined in:
- lib/auto_tagging/open_calais.rb
Constant Summary collapse
- API_SITE_URL =
'api.opencalais.com'
- API_PAGE_URL =
'/tag/rs/enrich'
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/auto_tagging/open_calais.rb', line 10 def api_key @api_key end |
Instance Method Details
#get_tags(content) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/auto_tagging/open_calais.rb', line 13 def (content) res = nil Net::HTTP.start(API_SITE_URL) do |http| req = Net::HTTP::Post.new(API_PAGE_URL) req.initialize_http_header() req.body = content.to_s res = http.request(req) end = JSON.parse(res.body).values.map { |value| value["name"] }.compact if res && res.code == "200" || [] end |