Skip to content

Instantly share code, notes, and snippets.

@jpmckinney
Created March 13, 2011 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmckinney/868531 to your computer and use it in GitHub Desktop.
Save jpmckinney/868531 to your computer and use it in GitHub Desktop.
Access Open Calais API with HTTParty
# snippet from HackMTL 2010
require 'httparty'
OPEN_CALAIS_KEY = 'demo'
class Calais
include HTTParty
base_uri 'api.opencalais.com'
def self.enlighten(content)
post '/enlighten/rest/', {
:headers => {
'Content-Type' => 'application/x-www-form-urlencoded',
},
:body => {
'licenseID' => OPEN_CALAIS_KEY,
'paramsXML' => '<c:params xmlns:c="http://s.opencalais.com/1/pred/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><c:processingDirectives c:contentType="text/html" c:outputFormat="application/json"></c:processingDirectives></c:params>',
'content' => content,
},
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment