2016-10-05 14 views
0

tweetpyを使用してストリーミングツイートの新機能私はツイーターから鍵を取得する必要があることをここに例を示しました。私はそうし、このコードを使用してこのstreamListenerの接続を確立しました。しかし、私は "エラー:401"を取得します。どんなアイデアも歓迎です!ありがとう!PythonのTweepy 2.7 streamlistenerの認証で、応答401としてエラー401を受け取ります

from slistener import SListener 
import time, tweepy, sys 

CONSUMER_KEY  = '' 
CONSUMER_SECRET = '' 
OAUTH_TOKEN  = '' 
OAUTH_TOKEN_SECRET = '' 


OAUTH_KEYS = {'consumer_key':CONSUMER_KEY, 'consumer_secret':CONSUMER_SECRET, 
'access_token_key':OAUTH_TOKEN, 'access_token_secret':OAUTH_TOKEN_SECRET} 

auth = tweepy.OAuthHandler(OAUTH_KEYS['consumer_key'], OAUTH_KEYS['consumer_secret']) 
api = tweepy.API(auth) 

def main(): 
    track = ['#Matthew', '#HurricaneMatthew'] 

    listen = SListener(api, 'myprefix') 
    stream = tweepy.Stream(auth, listen) 

    print "Streaming started..." 

    try: 
     stream.filter(track = track, languages=['en']) 
    except: 
     print "error!" 
     stream.disconnect() 

if __name__ == '__main__': 
    main() 

答えて

0

プログラムでこの行を変更するコードを取得しました。その洞察は他の投稿にも見られます。

# OAuth process, using the keys and tokens 
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) 
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) 

# Creation of the actual interface, using authentication 
api = tweepy.API(auth) 
関連する問題