Advertisement
Guest User

Untitled

a guest
Jan 10th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.09 KB | None | 0 0
  1. diff --git a/twitter.py b/twitter.py
  2. index faa6666..24dfe8e 100755
  3. --- a/twitter.py
  4. +++ b/twitter.py
  5. @@ -2150,6 +2150,7 @@ class Api(object):
  6.        >>> api.GetFollowers()
  7.        >>> api.GetFeatured()
  8.        >>> api.GetDirectMessages()
  9. +      >>> api.GetSentDirectMessages()
  10.        >>> api.PostDirectMessage(user, text)
  11.        >>> api.DestroyDirectMessage(id)
  12.        >>> api.DestroyFriendship(user)
  13. @@ -3180,6 +3181,42 @@ class Api(object):
  14.      data = self._ParseAndCheckTwitter(json)
  15.      return [DirectMessage.NewFromJsonDict(x) for x in data]
  16.  
  17. +  def GetSentDirectMessages(self, since=None, since_id=None, page=None):
  18. +    '''Returns a list of the direct messages sent by the authenticating user.
  19. +
  20. +    The twitter.Api instance must be authenticated.
  21. +
  22. +    Args:
  23. +      since:
  24. +        Narrows the returned results to just those statuses created
  25. +        after the specified HTTP-formatted date. [Optional]
  26. +      since_id:
  27. +        Returns results with an ID greater than (that is, more recent
  28. +        than) the specified ID. There are limits to the number of
  29. +        Tweets which can be accessed through the API. If the limit of
  30. +        Tweets has occured since the since_id, the since_id will be
  31. +        forced to the oldest ID available. [Optional]
  32. +      page:
  33. +        Specifies the page of results to retrieve.
  34. +        Note: there are pagination limits. [Optional]
  35. +
  36. +    Returns:
  37. +      A sequence of twitter.DirectMessage instances
  38. +    '''
  39. +    url = '%s/direct_messages/sent.json' % self.base_url
  40. +    if not self._oauth_consumer:
  41. +      raise TwitterError("The twitter.Api instance must be authenticated.")
  42. +    parameters = {}
  43. +    if since:
  44. +      parameters['since'] = since
  45. +    if since_id:
  46. +      parameters['since_id'] = since_id
  47. +    if page:
  48. +      parameters['page'] = page
  49. +    json = self._FetchUrl(url, parameters=parameters)
  50. +    data = self._ParseAndCheckTwitter(json)
  51. +    return [DirectMessage.NewFromJsonDict(x) for x in data]
  52. +
  53.    def PostDirectMessage(self, user, text):
  54.      '''Post a twitter direct message from the authenticated user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement