Skip to content

Instantly share code, notes, and snippets.

@nkint
Created November 21, 2014 12:01
Show Gist options
  • Save nkint/6b25cfbe11e6a0eb6ccb to your computer and use it in GitHub Desktop.
Save nkint/6b25cfbe11e6a0eb6ccb to your computer and use it in GitHub Desktop.
Python listen new tweet direct message and put on Yun Bridge as key-value
from twitter import *
auth = OAuth(
consumer_key='2yiyIW2qqGfwblk1Tk8BqiygP',
consumer_secret='1FWJu5810Gng0QdZylIMZlA0v1aGsLv9muTh8xn5kouE4ZE6EV',
token='2886635781-2mXPbGqS6x3szeUjdjB50DGEcI9P2OOVWVCX13z',
token_secret='1SMDFRZdHqea5sKEzNQTVHdnUdFh7s5jDab2qNL1zTqKB'
)
t = Twitter(auth=auth)
import sys
import subprocess
sys.path.insert(0, '/usr/lib/python2.7/bridge/')
from tcp import TCPJSONClient
json = TCPJSONClient('127.0.0.1', 5700)
json.send({'command':'put', 'key':'msg', 'value':'%i' % (23)})
count = 1
twitter_userstream = TwitterStream(auth=auth, domain='userstream.twitter.com')
for msg in twitter_userstream.user():
if 'direct_message' in msg:
print msg['direct_message']['text']
print count
json.send({'command':'put', 'key':'msg', 'value':'%i' % (count)})
count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment