Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2012 03:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Twitter API Access
import simplejson as json
import oauth2 as oauth
# Create your consumer with the proper key/secret.
consumer = oauth.Consumer(key="YOUR_CONSUMER_KEY",
# Create your token with the proper key/secret.
token = oauth.Token(key="YOUR_ACCESS_TOKEN",
# Request token URL for Twitter.
rate_limit_url = ""
# Create our client.
client = oauth.Client(consumer, token)
# The OAuth Client request works just like httplib2 for the most part.
resp, content = client.request(rate_limit_url, "GET")
# Parse the JSON into a Python dictionary.
data = json.loads(content)
# Print hourly limits.
print "Hourly => %3d" % (data['hourly_limit'])
print "Remaining => %3d" % (data['remaining_hits'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment