# HG changeset patch # User xitiomet # Date 1254451042 14400 # Node ID 82aae45f64f269f7b3a2ed30ac7a092d7562bf69 # Parent a58f4a7ad991fec8e823a10b8755de335e6585b9 Added GetMentions to twitter.py diff -r a58f4a7ad991fec8e823a10b8755de335e6585b9 -r 82aae45f64f269f7b3a2ed30ac7a092d7562bf69 twitter.py --- a/twitter.py Sun May 03 18:37:31 2009 +0000 +++ b/twitter.py Thu Oct 01 22:37:22 2009 -0400 @@ -1559,6 +1559,42 @@ self._CheckForTwitterError(data) return [Status.NewFromJsonDict(x) for x in data] + def GetMentions(self, since_id=None, max_id=None, count=None, page=None): + '''Returns a list of mentions of the authenticating user. + + The twitter.Api instance must be authenticated. + + Args: + since_id: + Returns only public statuses with an ID greater than (that is, + more recent than) the specified ID. [Optional] + max_id: + Optional. Returns only statuses with an ID less than (that is, older than) + or equal to the specified ID. + count: + Optional. Specifies the number of statuses to retrieve. May not be greater + than 200. + + Returns: + A sequence of twitter.Status instances + ''' + url = 'http://twitter.com/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: + parameters['count'] = count + if page: + parameters['page'] = page + json = self._FetchUrl(url, parameters=parameters) + data = simplejson.loads(json) + self._CheckForTwitterError(data) + return [Status.NewFromJsonDict(x) for x in data] + def GetFriends(self, user=None, page=None): '''Fetch the sequence of twitter.User instances, one for each friend. @@ -1634,7 +1670,7 @@ data = simplejson.loads(json) self._CheckForTwitterError(data) return User.NewFromJsonDict(data) - + def GetDirectMessages(self, since=None, since_id=None, page=None): '''Returns a list of the direct messages sent to the authenticating user.