Created
October 17, 2012 12:54
-
-
Save glarrain/3905363 to your computer and use it in GitHub Desktop.
Revisions
-
glarrain renamed this gist
Oct 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ from social_auth.backends.twitter import TwitterAuth def get_last_tweets(user): try: social_auth = user.social_auth.filter(provider='twitter')[0] except IndexError: -
omab created this gist
Aug 22, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ from urllib2 import urlopen from django.utils.simplejson import loads from oauth2 import Token from social_auth.backends.utils import build_consumer_oauth_request from social_auth.backends.twitter import TwitterAuth def last_tweets(user): try: social_auth = user.social_auth.filter(provider='twitter')[0] except IndexError: return [] request = build_consumer_oauth_request( TwitterAuth, Token.from_string(social_auth.extra_data['access_token']), 'https://api.twitter.com/1/statuses/home_timeline.json' ) response = '\n'.join(urlopen(request.to_url()).readlines()) return loads(response)