I am trying to connect to the Twitter REST API. I downloaded the twitter packages with pi in the command line. In another program I did I could connect to the stream Twitter API. This is my code:
try:
import json
except ImportError:
import simplejson as json
# Import the necessary methods from "twitter" library
from twitter import Twitter, OAuth, TwitterHTTPError, TwitterStream
# Variables that contains the user credentials to access Twitter API
ACCESS_TOKEN = ''
ACCESS_SECRET = ''
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
oauth = OAuth(ACCESS_TOKEN, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
twitter = Twitter(auth=OAuth)
twitter.statuses.home_timeline()
I am getting this error:
line 263, in __call__
headers.update(self.auth.generate_headers())
TypeError: generate_headers() missing 1 required positional argument: 'self'
How can I fix it?
I believe what you are trying to do is
twitter = Twitter(auth=oauth)