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):