Added check for authentication if user is getting rate limit status for an authenticated user

This commit is contained in:
Ryan McGrath 2009-07-01 05:18:48 -04:00
parent ecee9a438a
commit c69834935b

View file

@ -80,7 +80,10 @@ class setup:
if rate_for == "requestingIP":
return simplejson.load(urllib2.urlopen("http://twitter.com/account/rate_limit_status.json"))
else:
if self.authenticated is True:
return simplejson.load(self.opener.open("http://twitter.com/account/rate_limit_status.json"))
else:
print "You need to be authenticated to check for this."
except HTTPError, e:
if self.debug is True:
print e.headers
@ -147,15 +150,12 @@ class setup:
def updateStatus(self, status, in_reply_to_status_id = None):
if len(list(status)) > 140:
print "This status message is over 140 characters, but we're gonna try it anyway. Might wanna watch this!"
if self.authenticated is True:
try:
return simplejson.load(self.opener.open("http://twitter.com/statuses/update.json?", urllib.urlencode({"status": status}, {"in_reply_to_status_id": in_reply_to_status_id})))
except HTTPError, e:
if self.debug is True:
print e.headers
print "updateStatus() failed with a " + str(e.code) + " error code."
else:
print "updateStatus() requires you to be authenticated."
def destroyStatus(self, id):
if self.authenticated is True: