The tweepy stream.filter () method does not work properly

I have some problems with tweepy api.

I'm just trying to write a small application that gives me a single user status stream (more), but it would be nice to start from the very beginning :-)

now: my code looks like this:

    def main():
       config = ConfigParser.ConfigParser()
       config.read('twitter.cfg')

       username = config.get('Twitter', 'username')
       password = config.get('Twitter', 'password') 
           listener = StreamWatcherListener()

       stream = tweepy.Stream(username, password, listener, timeout=None)
       stream.filter('132897940')

in StreamWatcherListener I have a method "on_status" that prints status text when a new one arrives (everything works when I try to use stream.sample () instead of stream.filter ())

this id is my test score, so whenever I tweet, I should get a response in the console ... but nothing happens.

when i try

curl -d @following http://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:Password

in the terminal, as I could find on twitter api, everything works fine.

So maybe I am using the filter () method incorrectly?

any suggestions?

-andy

+1
2

stream.filter()

stream.filter(['1234567'])

et voilà

+7
class TweetListener(StreamListener):
    def on_status(self,status):           
        print "TWEET ARRIVED!!!"
        print "Tweet Text : %s" % status.text
        print "Author name : %s" % status.author.screen_name
        print "Time of creation : %s" % status.created_at
        print "Source of Tweet : %s" % status.source    
        time.sleep(10)       
        return True

    def on_error(self, status):        
       print status
       if status == 420:
            print "Too soon reconnected, Exiting!!"
            return False
        sys.exit()

def search_tweets():
    twitterStream = Stream(connect().auth, TweetListener())        
    twitterStream.filter(track=['Cricket','Maths','Army','Sports'],languages = ["en"],async=True)

async, . .

0

All Articles