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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -