Tweety for python:401错误

时间:2017-06-28 11:55:23

标签: python-3.x twitter-oauth tweepy

好的,我已经看到了很多这方面的问题,但最近没有人问过。我已尝试过来自不同地方的大约6或7个示例脚本,但在2天后,我得到的只是" 401"。

我尝试过的事情:

- many, many different scripts
- deleting my app on dev.twitter and making a new one (3 times)
- making a new account on dev.twitter
- regenerating keys on dev.twitter
- setting system time to use UTC on both windows and ubuntu
- swearing at it

有没有人有任何其他想法? (除了直接抓取推特XD)

(下面的代码只是在线提供的许多示例中的一个。显然xxxx是我的实际凭证,我已经无数次检查过它们:))

import tweepy


consumer_key = "xxxx"
consumer_secret = "xxxx"
access_token = "xxxx-xxxx"
access_token_secret = "xxxx"


class StdOutListener(tweepy.StreamListener):

    def on_error(self, status_code):
        print('Got an error with status code: ' + str(status_code))
        return True  # To continue listening

    def on_timeout(self):
        print('Timeout...')
        return True  # To continue listening


if __name__ == '__main__':
    listener = StdOutListener()
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret, callback='127.0.0.1')
    auth.set_access_token(access_token, access_token_secret)

    stream = tweepy.Stream(auth, listener)
    stream.filter(track=['#pythoncentral'])

#outputs"状态码出错:401"

0 个答案:

没有答案