小编sub*_*lex的帖子

使用tweepy时出现401错误

我正在运行以下程序.但我得到以下错误消息.401****401****(继续重复)

代码(来自某个论坛)基本上尝试连接到Twitter并获取推文.当它在ubuntu终端上运行时,会出现401错误消息.

import sys
import json
import pymongo
import tweepy
consumer_key="XX" ##all the keys and codes have to be strings
consumer_secret="XX"
access_token = "XX"
access_token_secret = "XX"
# This is the listener, resposible for receiving data

class StdOutListener(tweepy.StreamListener):

    def on_data(self, data):

        # Twitter returns data in JSON format - we need to decode it first

        decoded = json.loads(data)



        # Also, we convert UTF-8 to ASCII ignoring all bad characters sent by users

        print '@%s: %s' % (decoded['user']['screen_name'], decoded['text'].encode('ascii', 'ignore'))

        print …
Run Code Online (Sandbox Code Playgroud)

tweepy http-status-code-401 python-2.7

8
推荐指数
1
解决办法
3412
查看次数

标签 统计

http-status-code-401 ×1

python-2.7 ×1

tweepy ×1