Last active
December 19, 2015 06:29
-
-
Save jackboot7/5911955 to your computer and use it in GitHub Desktop.
Twython user streaming usage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twython import TwythonStreamer | |
APP_KEY = '<your app key>' | |
APP_SECRET = '<your app secret>' | |
OAUTH_TOKEN = '<your oauth token>' | |
OAUTH_TOKEN_SECRET = '<your oauth secret>' | |
""" | |
https://dev.twitter.com/docs/api/1.1/get/user | |
https://twython.readthedocs.org/en/latest/api.html#streaming-interface | |
https://dev.twitter.com/discussions/3877 | |
""" | |
class MyStreamer(TwythonStreamer): | |
def on_success(self, data): | |
if 'text' in data: | |
print data['text'].encode('utf-8') | |
def on_error(self, status_code, data): | |
print status_code, data | |
if __name__ == "__main__": | |
stream = MyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) | |
stream.user(**{"with": "followings"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment