This is my Python code that does not work anymore. I get this message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1".
The Python code basically uses the Python-Twitter library to ask Twitter for the status of user "x", and it then takes the last status and searches for the term "#driptwit". If found, it sends the ASCII value of 1 to the serial port (and to the Arduino). If #driptwitstop is found, it sends an ASCII value of 0. Lastly, it loops and checks the Twitter account every 15 seconds looking for changes.
As you can see, below is where you enter the keys you got from Twitter in the last step.
What should I need to change in the code to fix it?
Here is the actual code:
Enter code here
##Import Libraries``
import twitter
import serial
import time
##Authenticate yourself with Twitter
api = twitter.Api(consumer_key='consumerkeyhere', consumer_secret='consumersecrethere', access_token_key='accesskey', access_token_secret='accesssecret')
##Set to your serial port
ser = serial.Serial('COM3', 19200)
## Check serial port
def checkokay():
ser.flushInput()
time.sleep(3)
line = ser.readline()
time.sleep(3)
if line == ' ':
line = ser.readline()
print 'here'
## Welcome message
print 'Welcome To Drip Twit!'
print 'Making Coffee..'
def driptwit():
status = [ ]
x = 0
status = api.GetUserTimeline('X') ##Grab latest statuses
checkIt = [s.text for s in status] ##Put status in an array
drip = checkIt[0].split() ##Split first tweet into words
## Check for match and write to serial if match
if drip[0] == '#driptwit':
print 'Tweet received, making coffee'
ser.write('1')
elif drip[0] == '#driptwitstop': ##Break if done
ser.write('0')
print 'Stopped, awaiting instructions.'
else:
ser.write('0')
print 'Awaiting tweet'
while 1:
driptwit() ## Call driptwit function
time.sleep(15) ## Sleep for 15 seconds to avoid rate limiting.