Created
January 30, 2013 14:38
-
-
Save averagesecurityguy/4673693 to your computer and use it in GitHub Desktop.
Twitter Single User Oauth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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