twython/examples/stream.py
Mike Helmick c8b1202880 Added disconnect to TwythonStreamer, more tests, update example
* Stream and Twython core tests
* Import TwythonStreamError from twython

See more in 2.10.1 section of HISTORY.rst
2013-05-29 11:41:03 -04:00

19 lines
527 B
Python

from twython import TwythonStreamer
class MyStreamer(TwythonStreamer):
def on_success(self, data):
print data
# Want to disconnect after the first result?
# self.disconnect()
def on_error(self, status_code, data):
print status_code, data
# Requires Authentication as of Twitter API v1.1
stream = MyStreamer(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
stream.statuses.filter(track='twitter')
#stream.user(track='twitter')
#stream.site(follow='twitter')