A stub for further work on Streaming API integration - nothing to see here yet, move along...
This commit is contained in:
parent
23aeff128d
commit
46c93f4adb
1 changed files with 50 additions and 0 deletions
50
streaming.py
Normal file
50
streaming.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
The beginnings of Twitter Streaming API support in Twython. Don't expect this to work at all,
|
||||
consider it a stub for now. -- Ryan
|
||||
|
||||
Questions, comments? ryan@venodesigns.net
|
||||
"""
|
||||
|
||||
import httplib, urllib, urllib2, mimetypes, mimetools, socket, time
|
||||
|
||||
from urllib2 import HTTPError
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
try:
|
||||
import json as simplejson
|
||||
except ImportError:
|
||||
try:
|
||||
from django.utils import simplejson
|
||||
except:
|
||||
raise Exception("Twython (Streaming) requires the simplejson library (or Python 2.6) to work. http://www.undefined.org/python/")
|
||||
|
||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||
__version__ = "0.1"
|
||||
|
||||
class TwythonStreamingError(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def __str__(self):
|
||||
return repr(self.msg)
|
||||
|
||||
feeds = {
|
||||
"firehose": "http://stream.twitter.com/firehose.json",
|
||||
"gardenhose": "http://stream.twitter.com/gardenhose.json",
|
||||
"spritzer": "http://stream.twitter.com/spritzer.json",
|
||||
"birddog": "http://stream.twitter.com/birddog.json",
|
||||
"shadow": "http://stream.twitter.com/shadow.json",
|
||||
"follow": "http://stream.twitter.com/follow.json",
|
||||
"track": "http://stream.twitter.com/track.json",
|
||||
}
|
||||
|
||||
class stream:
|
||||
def __init__(self, username = None, password = None, feed = "spritzer", user_agent = "Twython Streaming"):
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.feed = feeds[feed]
|
||||
self.user_agent = user_agent
|
||||
self.connection_open = False
|
||||
Loading…
Add table
Add a link
Reference in a new issue