1
votes

I'm trying to make a twitterbot like: ( http://www.makeuseof.com/tag/how-to-build-a-raspberry-pi-twitter-bot/)

I'm getting back from the script:

root@raspberrypi:/home/pi# sudo python SillyTweeter.py

Traceback (most recent call last): File "SillyTweeter.py", line 11, in oauth_token=ACCESS_TOKEN, NameError: name 'ACCESS_TOKEN' is not defined

When searching on this site, the answers are different things. But I don't get why this is working for so many people, and not for me. I've tried: pip install oauthlib as was advised else on this site. But it did not help...

Please help me out! (I'm running Python 2.7)

The code:

{#!/usr/bin/env python  
import sys  
from twython import Twython 

CONSUMER_KEY = 'FAiuNnj8bdY7XdbTEjLDLLXpL' 
CONSUMER_SECRET = '1reyhokR4LrIGbXNBL5l2xFyJQibnY5TfbQj7b98dlqi2Hn1eO'  
ACCESS_KEY = '3347749960-EgKjwTz4mzNND62n6okkaHIzvmDPgHa4T1JihPQ'  
ACCESS_SECRET ='24Jstmr1SPBJW1bMxLg7ARZ75uoQnYzUXvfGpEs5YFo0L'  
t = Twython(app_key=CONSUMER_KEY, app_secret=CONSUMER_SECRET,          
oauth_token=ACCESS_TOKEN, oauth_token_secret=ACCESS_TOKEN_SECRET)

print t.getHomeTimeline() }

root@raspberrypi:/home/pi# sudo pip install twython

Requirement already satisfied (use --upgrade to upgrade): twython in /usr/local/lib/python2.7/dist-packages Requirement already satisfied (use --upgrade to upgrade): requests>=2.1.0 in /usr/local/lib/python2.7/dist-packages (from twython) Requirement already satisfied (use --upgrade to upgrade): requests-oauthlib>=0.4.0 in /usr/local/lib/python2.7/dist-packages (from twython) Requirement already satisfied (use --upgrade to upgrade): oauthlib>=0.6.2 in /usr/local/lib/python2.7/dist-packages (from requests-oauthlib>=0.4.0->twython)

1

1 Answers

3
votes

In your code, you are defining ACCESS_KEY and ACCESS_SECRET, but you use ACCESS_TOKEN and ACCESS_TOKEN_SECRET in the line it complains about. There are no variables in your code that are named ACCESS_TOKEN and ACCESS_TOKEN_SECRET, so I guess you meant to use mentioned ACCESS_KEY and ACCESS_SECRET.

Also, I hope the credentials in your code are just placeholders and not the real ones, since they really shouldn't be public. If they are, you should regenerate new ones in the Twitter development site to your app.