我正在尝试使用 Tweepy 检索 Twitter 数据,使用下面的代码,但我返回 401 错误,并且我重新生成了访问和秘密令牌,并且出现了相同的错误。
#imports
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
#setting up the keys
consumer_key = 'xxxxxxx'
consumer_secret = 'xxxxxxxx'
access_token = 'xxxxxxxxxx'
access_secret = 'xxxxxxxxxxxxx'
class TweetListener(StreamListener):
# A listener handles tweets are the received from the stream.
#This is a basic listener that just prints received tweets to standard output
def on_data(self, data):
print (data)
return True
def on_error(self, status):
print (status)
#printing all the tweets to the standard output
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
stream = Stream(auth, TweetListener())
t = u"#سوريا"
stream.filter(track=[t])
原文由 user3643380 发布,翻译遵循 CC BY-SA 4.0 许可协议
只需重置系统时钟即可。
如果验证 API 的请求来自声称它是 15 分钟 Twitter 时间之外的时间的服务器,它将失败并显示 401 错误。
谢谢你