Merge Handling into TwythonStreamer, update examples
This commit is contained in:
parent
c3e84bc8ee
commit
97a33ce8dd
5 changed files with 94 additions and 92 deletions
11
README.md
11
README.md
|
|
@ -105,22 +105,19 @@ except TwythonAuthError as e:
|
|||
##### Streaming API
|
||||
|
||||
```python
|
||||
from twython import TwythonStreamer, TwythonStreamHandler
|
||||
from twython import TwythonStreamer
|
||||
|
||||
|
||||
class MyHandler(TwythonStreamHandler):
|
||||
class MyStreamer(TwythonStreamer):
|
||||
def on_success(self, data):
|
||||
print data
|
||||
|
||||
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 = MyStreamer(APP_KEY, APP_SECRET,
|
||||
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||
|
||||
stream.statuses.filter(track='twitter')
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue