Trying to access the Twitter API returns AttributeError: 'module' object has no attribute 'oauth' -
why following error occur when attempt access twitter api?
attributeerror traceback (most recent call last) in () 17 18 ---> 19 auth = twitter.oauth.oauth(access_token_key,access_token_secret,consumer_key,consumer_secret) 20 #twitter = twitter.twitter(auth=twitter.oauth.oauth(access_token_key,access_token_secret,consumer_key,consumer_secret)) 21 twitter_api = twitter.twitter(auth=auth)
attributeerror: 'module' object has no attribute 'oauth'
my code:
import twitter #from twitter import * #from twitter import oauth consumer_key = '' consumer_secret ='' access_token_key = '' access_token_secret = '' auth = twitter.oauth.oauth(access_token_key,access_token_secret,consumer_key,consumer_secret) #twitter = twitter.twitter(auth=twitter.oauth.oauth(access_token_key,access_token_secret,consumer_key,consumer_secret)) twitter_api = twitter.twitter(auth=auth) print twitter
i read documentation carefully.
from link mentioned:
from twitter import * t = twitter( auth=oauth(token, token_key, con_secret, con_secret_key))
so see auth=oauth
not auth=oauth.oauth
in case have import twitter
, difference that's there you'll need add twitter
before each attribute have done, still don't need oauth
import twitter t = twitter.twitter( auth=twitter.oauth(token, token_key, con_secret, con_secret_key))
Comments
Post a Comment