Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit e589979

Browse files
committed
Add page option in GetDirectMessages
If we have more than 200 unread messages, you can't reach them with the count option. Page option is the answer for this matter.
1 parent 388405f commit e589979

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

twitter/api.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,8 @@ def GetDirectMessages(self,
19491949
count=None,
19501950
include_entities=True,
19511951
skip_status=False,
1952-
full_text=False):
1952+
full_text=False,
1953+
page=None):
19531954
"""Returns a list of the direct messages sent to the authenticating user.
19541955
19551956
The twitter.Api instance must be authenticated.
@@ -1978,6 +1979,11 @@ def GetDirectMessages(self,
19781979
full_text:
19791980
When set to True full message will be included in the returned message
19801981
object if message length is bigger than 140 characters. [Optional]
1982+
page:
1983+
If you want more than 200 messages, you can use this and get 20 messages
1984+
each time. You must recall it and increment the page value until it
1985+
return nothing. You can't use count option with it. First value is 1 and
1986+
not 0.
19811987
19821988
Returns:
19831989
A sequence of twitter.DirectMessage instances
@@ -2002,6 +2008,8 @@ def GetDirectMessages(self,
20022008
parameters['skip_status'] = 1
20032009
if full_text:
20042010
parameters['full_text'] = 'true'
2011+
if page:
2012+
parameters['page'] = page
20052013

20062014
json_data = self._RequestUrl(url, 'GET', data=parameters)
20072015
data = self._ParseAndCheckTwitter(json_data.content)

0 commit comments

Comments
 (0)