Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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