2017-03-15 9 views
-1

私はPython上でモジュールをインストールするのはかなり新しいです。私はTweepyを使い始めようとしていますが、間違いがあります。tweepyを認証する構文エラー

私は

import tweepy 
auth = tweepy.OAuthHandler(MYCONSUMERKEY, MYCONSUMERSECRET) 

を実行した。しかし、次のエラーが返されます。

File "<stdin>", line 1 
    auth = tweepy.OAuthHandler(MYCONSUMERKEY, MYCONSUMERSECRET) 
                  ^
SyntaxError: invalid syntax 

ここで間違って行くことができるか任意のアイデアを?私はOSX El CapitanでPython 2.7を使っています

+0

実際にあなたのエラーメッセージを指し示しているのはどこですか? – Barmar

+0

自分の秘密の最後の文字の直下にあります。それはありがとう! –

答えて

0

私はあなたのTwitter Appsの資格情報を持っていると推測します(それ以外の場合は何も動作しません)。

は(あなたが必要な資格情報を持っていると仮定して)これにより

import tweepy 

# Fill this up with the Twitter Apps Credentials (get them @ apps.twitter.com) 
consumer_key = "Your consumer Key" 
consumer_secret = "Your consumer Key Secret" 
access_token = "Your access Token" 
access_token_secret = "Your access Token Secret" 

auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 
auth.set_access_token(access_token, access_token_secret) 

api = tweepy.API(auth) 

print "User Name:", api.me().name 
print "Account (@):", api.me().screen_name 

を次のコードの一部を使用して、あなたは上のベースTweepy(最後の2行を、使用してTwitterのAPIとの対話を開始するための基本的な枠組みを持っていますあなたのTwitter資格情報は、あなたの名前と@usernameをTwitterに印刷する必要があります。

関連する問題