Fixing streaming

This commit is contained in:
Mike Helmick 2013-05-02 15:12:36 -04:00
parent e18bff97d3
commit c3e84bc8ee
10 changed files with 290 additions and 81 deletions

View file

@ -103,23 +103,26 @@ except TwythonAuthError as e:
```
##### Streaming API
*Usage is as follows; it's designed to be open-ended enough that you can adapt it to higher-level (read: Twitter must give you access)
streams.*
```python
from twython import Twython
from twython import TwythonStreamer, TwythonStreamHandler
def on_results(results):
"""A callback to handle passed results. Wheeee.
"""
print results
class MyHandler(TwythonStreamHandler):
def on_success(self, data):
print data
Twython.stream({
'username': 'your_username',
'password': 'your_password',
'track': 'python'
}, on_results)
def on_error(self, status_code, data):
print status_code, data
handler = MyHandler()
# Requires Authentication as of Twitter API v1.1
stream = TwythonStreamer(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
handler)
stream.statuses.filter(track='twitter')
```
Notes