I'm doing it exactly the same way other SO user did
for follower in api.followers_ids('twitter'):
print api.get_user(follower).screen_name
But getting the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 185, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 168, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{'message': 'Bad Authentication data', 'code': 215}]
Streaming working just find so I assume authentication process went normally.
This problem is not limited to Tweepy, for example I've tried Twython
t = Twython(app_key=consumer_key,
app_secret=consumer_secret,
oauth_token=access_token,
oauth_token_secret=access_token_secret)
And got very similar error:
File "downloader.py", line 14, in <module>
auth = t.get_authentication_tokens()
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 260, in get_authentication_tokens
raise TwythonAuthError(response.content, error_code=response.status_code)
twython.exceptions.TwythonAuthError: Twitter API returned a 401 (Unauthorized), Failed to validate oauth signature and token
I've triple checked my keys and tokens and sure they are allright. What is the root of the problem I'm experiencing?
p.s. I think my problem is deeper.
I cannot get example code for Twython working. The following code:
t = Twython(app_key=consumer_key,
app_secret=consumer_secret,
oauth_token=access_token,
oauth_token_secret=access_token_secret)
try:
search_results = t.search(q='WebsDotCom', count=50)
except TwythonError as e:
print e
for tweet in search_results['statuses']:
print 'Tweet from @%s Date: %s' % (tweet['user']['screen_name'].encode('utf-8'), tweet['created_at'])
print tweet['text'].encode('utf-8'), '\n'
produces
File "downloader.py", line 19, in <module>
search_results = t.search(q='WebsDotCom', count=50)
File "/usr/local/lib/python2.7/dist-packages/twython/endpoints.py", line 130, in search
return self.get('search/tweets', params=params)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 219, in get
return self.request(endpoint, params=params, version=version)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 213, in request
content = self._request(url, method=method, params=params, api_call=url)
File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 134, in _request
response = func(url, **requests_args)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 254, in get
return self.request('get', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 521, in send
r = self.auth(self)
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/core.py", line 58, in __call__
if is_form_encoded or extract_params(r.body):
AttributeError: 'Request' object has no attribute 'body'
I think it is somehow related to oauth, but updating requests_oauthlib haven't helped.