1

I am using Python-twitter Arduino to turn on a light on the Arduino board when someones does a mention to an specific user in twitter. I am able to do turn on the light if I use my username and use the this status = api.GetUserTimeline('username') I would prefer that when someones mentions the username anywhere in twitter this lights turns on. Any ideas how I can I do this?

Below is an example of the code.

#status = api.GetUserTimeline('username') ##grab latest statuses

status = api.GetMentions(count=1) ##How get this to work properly?

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] == '#action_go':
    print 'Tweet Recieved, Turning the light on!'
    ser.write('1')
elif drip[0] == '#action_stop': ##break if done
    ser.write('0')
    print 'stopped, awaiting instructions.'
else:
    ser.write('0')
    print 'Awaiting Tweet'
toblerone_country
  • 577
  • 14
  • 26

1 Answers1

0

There are two options for you.

Firstly, you can check your mentions - https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline

Calling that URL will show you the most recent times @username has been mentioned.

If you want to have the light change as soon as you are mentioned, you will need to use the Streaming API https://dev.twitter.com/streaming/reference/post/statuses/filter

Set up a filter for @username and you'll be instantly alerted once you are mentioned.

Terence Eden
  • 14,034
  • 3
  • 48
  • 89