tweepy / tweepy

Twitter for Python!
https://www.tweepy.org
MIT License
10.45k stars 4.6k forks source link

Direct Messages Cursor(pagination) #1894

Closed manojbanoth closed 2 years ago

manojbanoth commented 2 years ago

tweepy version ==4.9.0

api.get_direct_messages(count=500 , cursor=-1) with this code gave me an error Invalid cursor

tweepy.Cursor(api.get_direct_messages(count=100)) with this code gave me an error ('This method does not perform pagination') api.get_direct_messages(count=5000) gives me only last 50 messages

But the document says pagination is possible.
[https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/list-events]

I want to extract all the DM for the past 30 days within the rate limit please do needful

Harmon758 commented 2 years ago

With tweepy.Cursor(api.get_direct_messages(count=100)), you're passing the results of your call to API.get_direct_messages to Cursor. You need to pass the method itself.

See the documentation on pagination using Cursor for more information.