Fixed getUserTimeline(), as it was... way out of whack. Should now properly detect which method of identification is needed for the userTimeline scenario.
This commit is contained in:
parent
b71dd218aa
commit
63cf9dba3a
1 changed files with 13 additions and 5 deletions
14
tango.py
14
tango.py
|
|
@ -105,15 +105,23 @@ class setup:
|
||||||
print "getFriendsTimeline() requires you to be authenticated."
|
print "getFriendsTimeline() requires you to be authenticated."
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getUserTimeline(self, **kwargs):
|
def getUserTimeline(self, id = None, **kwargs):
|
||||||
|
if id is not None and kwargs.has_key("user_id") is False and kwargs.has_key("screen_name") is False:
|
||||||
|
userTimelineURL = self.constructApiURL("http://twitter.com/statuses/user_timeline/" + id + ".json", kwargs)
|
||||||
|
elif id is None and kwargs.has_key("user_id") is False and kwargs.has_key("screen_name") is False and self.authenticated is True:
|
||||||
userTimelineURL = self.constructApiURL("http://twitter.com/statuses/user_timeline/" + self.username + ".json", kwargs)
|
userTimelineURL = self.constructApiURL("http://twitter.com/statuses/user_timeline/" + self.username + ".json", kwargs)
|
||||||
|
else:
|
||||||
|
userTimelineURL = self.constructApiURL("http://twitter.com/statuses/user_timeline.json", kwargs)
|
||||||
try:
|
try:
|
||||||
|
# We do our custom opener if we're authenticated, as it helps avoid cases where it's a protected user
|
||||||
|
if self.authenticated is True:
|
||||||
|
return simplejson.load(self.opener.open(userTimelineURL))
|
||||||
|
else:
|
||||||
return simplejson.load(urllib2.urlopen(userTimelineURL))
|
return simplejson.load(urllib2.urlopen(userTimelineURL))
|
||||||
except HTTPError, e:
|
except HTTPError, e:
|
||||||
if self.debug is True:
|
if self.debug is True:
|
||||||
print e.headers
|
print e.headers
|
||||||
print "Failed with a " + str(e.code) + " error code. Does this user hide/protect their updates? If so, you'll need to authenticate and be their friend to get their timeline."
|
print "Failed with a " + str(e.code) + " error code. Does this user hide/protect their updates? If so, you'll need to authenticate and be their friend to get their timeline."
|
||||||
pass
|
|
||||||
|
|
||||||
def getUserMentions(self, **kwargs):
|
def getUserMentions(self, **kwargs):
|
||||||
if self.authenticated is True:
|
if self.authenticated is True:
|
||||||
|
|
@ -523,7 +531,7 @@ class setup:
|
||||||
else:
|
else:
|
||||||
print "getBlockedIDs() requires you to be authenticated."
|
print "getBlockedIDs() requires you to be authenticated."
|
||||||
|
|
||||||
def searchTwitter(self, search_query, optional_page):
|
def searchTwitter(self, search_query, optional_page = "1"):
|
||||||
params = urllib.urlencode({'q': search_query, 'rpp': optional_page}) # Doesn't hurt to do pages this way. *shrug*
|
params = urllib.urlencode({'q': search_query, 'rpp': optional_page}) # Doesn't hurt to do pages this way. *shrug*
|
||||||
try:
|
try:
|
||||||
return simplejson.load(urllib2.urlopen("http://search.twitter.com/search.json", params))
|
return simplejson.load(urllib2.urlopen("http://search.twitter.com/search.json", params))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue