Worked in some try/catch support for loading and hitting the API - needs to happen for other functions as well, once I have more time.
This commit is contained in:
parent
1f544c6aaf
commit
c47d6008a0
1 changed files with 11 additions and 5 deletions
6
tango.py
6
tango.py
|
|
@ -31,11 +31,17 @@ class setup:
|
|||
return queryURL
|
||||
|
||||
def getPublicTimeline(self):
|
||||
try:
|
||||
publicTimeline = simplejson.load(urllib2.urlopen("http://twitter.com/statuses/public_timeline.json"))
|
||||
formattedTimeline = []
|
||||
for tweet in publicTimeline:
|
||||
formattedTimeline.append(tweet['text'])
|
||||
return formattedTimeline
|
||||
except IOError, e:
|
||||
if hasattr(e, 'code'):
|
||||
return "Loading API failed with HTTP Status Code " + e.code
|
||||
else:
|
||||
return "God help us all, Scotty, she's dead and we're not sure why."
|
||||
|
||||
def getUserTimeline(self, **kwargs):
|
||||
# 99% API compliant, I think - need to figure out Gzip compression and auto-getting based on authentication
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue