Skip to content

Instantly share code, notes, and snippets.

@vpekar
Last active February 3, 2016 14:48
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 vpekar/c4d939edaffc96eb9f76 to your computer and use it in GitHub Desktop.
Save vpekar/c4d939edaffc96eb9f76 to your computer and use it in GitHub Desktop.
import urllib, urllib2, json
from pprint import pprint
URL = "<ACCESS-URL>"
text = "The food was great, but the service was slow."
opener = urllib2.build_opener(urllib2.HTTPHandler)
params = {'text': text, 'categories': 1, 'sentiment': 1,
'annotate': 1}
headers = {"<ACCESS-KEY-HEADER>": "<ACCESS-KEY>"}
request = urllib2.Request(URL, urllib.urlencode(params),
headers=headers)
response = opener.open(request)
opener.close()
data = json.loads(response.read())
pprint(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment