Skip to content

Instantly share code, notes, and snippets.

@jackboot7
Last active December 19, 2015 06:29
Show Gist options
  • Save jackboot7/5911955 to your computer and use it in GitHub Desktop.
Save jackboot7/5911955 to your computer and use it in GitHub Desktop.
Twython user streaming usage.
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