@@ -4789,6 +4789,47 @@ def GetStreamSample(self, delimited=None, stall_warnings=None):
47894789 data = self ._ParseAndCheckTwitter (line )
47904790 yield data
47914791
4792+ def GetStreamFilter (self , follow = None , track = None , locations = None ,
4793+ delimited = None , stall_warning = None ):
4794+ '''Returns a filtered view of public statuses.
4795+
4796+ args:
4797+ follow: a list of user ids to track [optional]
4798+ track: a list of expressions to track [optional]
4799+ locations: a list of pairs strings 'lat,lon', specifying
4800+ bounding boxes for the tweets' origin [optional]
4801+ delimited: specifies a message length [optional]
4802+ stall_warnings: set to True to deliver stall warnings [optional]
4803+
4804+ returns:
4805+ a twitter stream
4806+
4807+ '''
4808+ if not self .__auth :
4809+ raise TwitterError ("twitter.Api instance must be authenticated" )
4810+
4811+ if all ((follow is None , track is None , locations is None )):
4812+ raise ValueError ('No filter parameters specified.' )
4813+
4814+ data = {}
4815+ if follow is not None :
4816+ data ['follow' ] = ',' .join (follow )
4817+ if track is not None :
4818+ data ['track' ] = ',' .join (track )
4819+ if locations is not None :
4820+ data ['locations' ] = ',' .join (locations )
4821+ if delimited is not None :
4822+ data ['delimited' ] = str (delimited )
4823+ if delimited is not None :
4824+ data ['stall_warning' ] = str (stall_warning )
4825+
4826+ url = '%s/statuses/filter.json' % self .stream_url
4827+ json = self ._RequestStream (url , 'POST' , data = data )
4828+ for line in json .iter_lines ():
4829+ if line :
4830+ data = self ._ParseAndCheckTwitter (line )
4831+ yield data
4832+
47924833 def VerifyCredentials (self ):
47934834 '''Returns a twitter.User instance if the authenticating user is valid.
47944835
0 commit comments