Replaced complicated GetReplies stuff with a simple implementation of GetMentions
This commit is contained in:
parent
7f0b7c8c3b
commit
f65b743b32
|
@ -76,13 +76,7 @@ class MyTwitter():
|
||||||
if self.list is None or self.list == 'Home':
|
if self.list is None or self.list == 'Home':
|
||||||
statuses = self.api.GetHomeTimeline(count=self.num_entries)
|
statuses = self.api.GetHomeTimeline(count=self.num_entries)
|
||||||
elif self.list == '@' + self.username:
|
elif self.list == '@' + self.username:
|
||||||
statuses = []
|
statuses = self.api.GetMentions(count=self.num_entries)
|
||||||
page = 1
|
|
||||||
num_needed = self.num_entries
|
|
||||||
while num_needed > 0:
|
|
||||||
statuses.extend(self.api.GetReplies(page=page))
|
|
||||||
num_needed -= 20
|
|
||||||
page += 1
|
|
||||||
else:
|
else:
|
||||||
statuses = self.api.GetListStatuses(self.list, per_page=self.num_entries)
|
statuses = self.api.GetListStatuses(self.list, per_page=self.num_entries)
|
||||||
|
|
||||||
|
|
53
python-twitter-GetMentions.patch
Normal file
53
python-twitter-GetMentions.patch
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
diff -r 51ac454d5d89 twitter.py
|
||||||
|
--- a/twitter.py Thu Dec 31 15:06:42 2009 -0500
|
||||||
|
+++ b/twitter.py Sun Apr 11 01:08:53 2010 -0400
|
||||||
|
@@ -722,6 +722,49 @@
|
||||||
|
self._CheckForTwitterError(data)
|
||||||
|
return [NewStatusFromJsonDict(x) for x in data]
|
||||||
|
|
||||||
|
+ def GetMentions(self, since_id=None, max_id=None, count=None, page=None):
|
||||||
|
+ '''Get a sequence of status messages representing status updates containing
|
||||||
|
+ @username for the authenticated user
|
||||||
|
+
|
||||||
|
+ Args:
|
||||||
|
+ since_id:
|
||||||
|
+ Returns only public statuses with an ID greater than (that is,
|
||||||
|
+ more recent than) the specified ID. [Optional]
|
||||||
|
+ max_id:
|
||||||
|
+ Returns only statuses with an ID less than (that is, older
|
||||||
|
+ than) or equal to the specified ID. [optional]
|
||||||
|
+ count:
|
||||||
|
+ Specifies the number of statuses to retrieve. May not be
|
||||||
|
+ greater than 200. [optional]
|
||||||
|
+ page:
|
||||||
|
+ Specifies the page of results to retrieve. Note: there are
|
||||||
|
+ pagination limits. [optional]
|
||||||
|
+
|
||||||
|
+ Returns:
|
||||||
|
+ A sequence of Status instances, one for each mention of the user.
|
||||||
|
+ '''
|
||||||
|
+ url = 'http://api.twitter.com/1/statuses/mentions.json'
|
||||||
|
+ if not self._username:
|
||||||
|
+ raise TwitterError("The twitter.Api instance must be authenticated.")
|
||||||
|
+ parameters = {}
|
||||||
|
+ if since_id:
|
||||||
|
+ parameters['since_id'] = since_id
|
||||||
|
+ if max_id:
|
||||||
|
+ parameters['max_id'] = max_id
|
||||||
|
+ if count:
|
||||||
|
+ try:
|
||||||
|
+ if int(count) > 200:
|
||||||
|
+ raise TwitterError("'count' may not be greater than 200")
|
||||||
|
+ except ValueError:
|
||||||
|
+ raise TwitterError("'count' must be an integer")
|
||||||
|
+ parameters['count'] = count
|
||||||
|
+ if page:
|
||||||
|
+ parameters['page'] = page
|
||||||
|
+ json = self._FetchUrl(url, parameters=parameters)
|
||||||
|
+ data = simplejson.loads(json)
|
||||||
|
+ self._CheckForTwitterError(data)
|
||||||
|
+ return [NewStatusFromJsonDict(x) for x in data]
|
||||||
|
+
|
||||||
|
def GetFavorites(self,
|
||||||
|
user=None,
|
||||||
|
page=None):
|
Reference in New Issue
Block a user