使用 Tweepy 检索 Twitter 数据时出现 401 错误

新手上路,请多包涵

我正在尝试使用 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 许可协议

阅读 838
1 个回答

只需重置系统时钟即可。

如果验证 API 的请求来自声称它是 15 分钟 Twitter 时间之外的时间的服务器,它将失败并显示 401 错误。

谢谢你

原文由 Prakhar Mishra 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题