Skip to content

Instantly share code, notes, and snippets.

@averagesecurityguy
Created January 30, 2013 14:38
Show Gist options
  • Save averagesecurityguy/4673693 to your computer and use it in GitHub Desktop.
Save averagesecurityguy/4673693 to your computer and use it in GitHub Desktop.
Twitter Single User Oauth
import requests
import oauth
class Twitter():
def __init__(self):
self.consumer_key = ''
self.consumer_secret = ''
self.token = ''
self.token_secret = ''
self.__base = 'https://api.twitter.com/1.1'
self.__ssn = requests.Session()
self.__ssn.auth = oauth.TwitterSingleOAuth(self.consumer_key,
self.consumer_secret,
self.token,
self.token_secret)
def get_mentions(self):
r = self.__ssn.get(self.__base + '/statuses/mentions_timeline.json')
return r.json()
if __name__ == '__main__':
t = Twitter()
print '\n'.join(t.get_mentions())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment