Commit 59f6634a authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Include all parameters when signing request for OAuth.

parent a70c752a
......@@ -83,12 +83,13 @@ class Stream(object):
self.api = API()
self.headers = options.get("headers") or {}
self.parameters = None
self.body = None
def _run(self):
# Authenticate
url = "%s://%s%s" % (self.scheme, self.host, self.url)
self.auth.apply_auth(url, 'GET', self.headers, None)
self.auth.apply_auth(url, 'POST', self.headers, self.parameters)
# Connect and process the stream
error_counter = 0
......@@ -166,6 +167,7 @@ class Stream(object):
self._run()
def firehose(self, count=None, async=False):
self.parameters = {'delimited': 'length'}
if self.running:
raise TweepError('Stream object already connected!')
self.url = '/%i/statuses/firehose.json?delimited=length' % STREAM_VERSION
......@@ -174,12 +176,14 @@ class Stream(object):
self._start(async)
def retweet(self, async=False):
self.parameters = {'delimited': 'length'}
if self.running:
raise TweepError('Stream object already connected!')
self.url = '/%i/statuses/retweet.json?delimited=length' % STREAM_VERSION
self._start(async)
def sample(self, count=None, async=False):
self.parameters = {'delimited': 'length'}
if self.running:
raise TweepError('Stream object already connected!')
self.url = '/%i/statuses/sample.json?delimited=length' % STREAM_VERSION
......@@ -188,19 +192,20 @@ class Stream(object):
self._start(async)
def filter(self, follow=None, track=None, async=False, locations=None):
params = {}
self.parameters = {}
self.headers['Content-type'] = "application/x-www-form-urlencoded"
if self.running:
raise TweepError('Stream object already connected!')
self.url = '/%i/statuses/filter.json?delimited=length' % STREAM_VERSION
if follow:
params['follow'] = ','.join(map(str, follow))
self.parameters['follow'] = ','.join(map(str, follow))
if track:
params['track'] = ','.join(map(str, track))
self.parameters['track'] = ','.join(map(str, track))
if locations and len(locations) > 0:
assert len(locations) % 4 == 0
params['locations'] = ','.join(['%.2f' % l for l in locations])
self.body = urllib.urlencode(params)
self.parameters['locations'] = ','.join(['%.2f' % l for l in locations])
self.body = urllib.urlencode(self.parameters)
self.parameters['delimited'] = 'length'
self._start(async)
def disconnect(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment