diff -r 51ac454d5d89 twitter.py --- a/twitter.py Thu Dec 31 15:06:42 2009 -0500 +++ b/twitter.py Sun Apr 11 00:33:25 2010 -0400 @@ -493,6 +493,52 @@ self._CheckForTwitterError(data) return [NewStatusFromJsonDict(x) for x in data] + def GetHomeTimeline(self, + count=None, + max_id=None, + since_id=None, + page=None): + '''Fetch the sequence of Status messages for the authenticated user and + the user's friends. Includes retweets. + + The twitter.Api instance must be authenticated. + + Args: + count: + Specifies the number of statuses to retrieve. May not be + greater than 200. [Optional] + since: + Narrows the returned results to just those statuses created + after the specified HTTP-formatted date. [Optional] + since_id: + Returns only public statuses with an ID greater than (that is, + more recent than) the specified ID. [Optional] + + Returns: + A sequence of Status instances, one for each message + ''' + if not self._username: + raise TwitterError("The twitter.Api instance must be authenticated.") + url = 'http://api.twitter.com/1/statuses/home_timeline.json' + parameters = {} + if count is not None: + 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 max_id: + parameters['max_id'] = max_id + if since_id: + parameters['since_id'] = since_id + 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 GetUserTimeline(self, id=None, user_id=None,