使用 Tweepy/Python 进入受保护的 Twitter 流

Tapping into protected Twitter streams using Tweepy/Python

我正在编写一个小型 Twitter 机器人,使用 Tweepy 作为 Python Twitter 包装器,我正在尝试访问由我的 Twitter 帐户设置为私人的朋友写的推文。 机器人跟随他们,反之亦然,但出于某种原因,我无法利用受保护朋友的推文。 这是处理 Twitter 流的代码片段:

auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=[hotword])

有人知道如何正确地做吗? 干杯!

stream/filter API 不会 return 保护内容。

来自docs

Returns public statuses that match one or more filter predicates.

您甚至无法使用 follow parameter 来查看他们,该 follow parameter 指定了您对 Streaming API 感兴趣的用户:

indicating the users whose Tweets should be delivered on the stream. Following protected users is not supported.

要获得受保护的推文,您需要 REST 端点。