X Tutup
Skip to content

Commit 80c3789

Browse files
committed
Merge git://gitorious.org/osamak-python-twitter/osamak-python-twitter
2 parents fc07fc7 + 9bb81ea commit 80c3789

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

twitter.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,7 @@ class Api(object):
21582158
>>> api.GetFollowers()
21592159
>>> api.GetFeatured()
21602160
>>> api.GetDirectMessages()
2161+
>>> api.GetSentDirectMessages()
21612162
>>> api.PostDirectMessage(user, text)
21622163
>>> api.DestroyDirectMessage(id)
21632164
>>> api.DestroyFriendship(user)
@@ -3261,6 +3262,42 @@ def GetDirectMessages(self, since=None, since_id=None, page=None):
32613262
data = self._ParseAndCheckTwitter(json)
32623263
return [DirectMessage.NewFromJsonDict(x) for x in data]
32633264

3265+
def GetSentDirectMessages(self, since=None, since_id=None, page=None):
3266+
'''Returns a list of the direct messages sent by the authenticating user.
3267+
3268+
The twitter.Api instance must be authenticated.
3269+
3270+
Args:
3271+
since:
3272+
Narrows the returned results to just those statuses created
3273+
after the specified HTTP-formatted date. [Optional]
3274+
since_id:
3275+
Returns results with an ID greater than (that is, more recent
3276+
than) the specified ID. There are limits to the number of
3277+
Tweets which can be accessed through the API. If the limit of
3278+
Tweets has occured since the since_id, the since_id will be
3279+
forced to the oldest ID available. [Optional]
3280+
page:
3281+
Specifies the page of results to retrieve.
3282+
Note: there are pagination limits. [Optional]
3283+
3284+
Returns:
3285+
A sequence of twitter.DirectMessage instances
3286+
'''
3287+
url = '%s/direct_messages/sent.json' % self.base_url
3288+
if not self._oauth_consumer:
3289+
raise TwitterError("The twitter.Api instance must be authenticated.")
3290+
parameters = {}
3291+
if since:
3292+
parameters['since'] = since
3293+
if since_id:
3294+
parameters['since_id'] = since_id
3295+
if page:
3296+
parameters['page'] = page
3297+
json = self._FetchUrl(url, parameters=parameters)
3298+
data = self._ParseAndCheckTwitter(json)
3299+
return [DirectMessage.NewFromJsonDict(x) for x in data]
3300+
32643301
def PostDirectMessage(self, user, text):
32653302
'''Post a twitter direct message from the authenticated user
32663303

0 commit comments

Comments
 (0)
X Tutup