【发布时间】:2018-10-21 09:19:28
【问题描述】:
我的问题是关于返回的 twython...
401 b'<html>\\n<head>\\n<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"/>\\n<title>Error 401
Unauthorized</title>\n</head>\n<body>\n<h2>HTTP ERROR: 401</h2>\n<p>Problem
accessing \'/1.1/statuses/filter.json\'. Reason:\n<pre>
Unauthorized</pre>\n</body>\n</html>\n'
我已经尝试重新生成消费者密钥和秘密以及访问令牌和秘密,但它仍然返回相同的东西......下面是我的代码
tweets = []
class MyStreamer(TwythonStreamer):
def on_success(self, data):
""" Stores tweet data as dict """
# Collect only English Tweets
if data['lang'] == 'en':
tweets.append(data)
print("Received Tweet #", len(tweets))
# Stop when 1000 tweets are collected
if len(tweets) >= 1000:
self.disconnect()
def on_error(self, status_code, data):
print(status_code, data)
self.disconnect()
stream = MyStreamer(CONSUMER_KEY, CONSUMER_SECRET,
ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# Starts consuming public Statuses that contain the keyword 'cola'
stream.statuses.filter(track='cola')
【问题讨论】:
标签: python-3.x api twitter twython