Tweepy/如何使用直接消息方法获取旧的DMs?

2024-05-14 20:52:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Python和Tweepy非常陌生。在

我想,比如说,看看我收到的所有DMs的文本。在

import tweepy

consumer_key = "XXXX"
consumer_secret = "YYY"

access_token = "ZZZ"
access_token_secret = "AAA"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)


since_id = "11223344556677889" 
#This is the ID of a month-old DM.  I want to get "all" DMs since then, tho I think I'm limited to 200 per call huh?

direct_messages = tweepy.Cursor(api.direct_messages, since_id=since_id).items()

for dm in direct_messages:
        print dm.text

这是最近的200个DMs。那不是我想要的。我要旧的DMs,从身份证开始

FWIW,我知道DM存在,因为它正确地返回它:

^{pr2}$

Tags: tokeytokenauthapiidsecretaccess
1条回答
网友
1楼 · 发布于 2024-05-14 20:52:06

看起来这是一个twitter API限制:

Returns the 20 most recent direct messages sent to the authenticating user. Includes detailed information about the sender and recipient user. You can request up to 200 direct messages per call, and only the most recent 200 DMs will be available using this endpoint.

https://dev.twitter.com/rest/reference/get/direct_messages

相关问题 更多 >

    热门问题