twtrbt
twtrbt

Reputation: 3

Can not connect to Twitter using Tweepy Streaming

Trying to check whether connection established or not, but nothing happened

I used on_connect to understand but got nothing:

import tweepy
import time

class InOutStreamListener(tweepy.StreamListener):
    def on_connect(self):
        print 'Connected'    

    def disconnect(self):
        if self.running is False:
            return
        self.running = False

    def on_friends(self, friends):
        print friends[0]

auth = tweepy.OAuthHandler('code', 'code')
auth.set_access_token('code', 'code')

l = InOutStreamListener()    
streamer = tweepy.Stream(auth, l)

time.sleep(15)    
streamer.disconnect()

Upvotes: 0

Views: 398

Answers (1)

miles82
miles82

Reputation: 6794

You only created a Stream, you didn't start it, see the docs.

In this example we will use filter to stream all tweets containing the word python. The track parameter is an array of search terms to stream.

myStream.filter(track=['python'])

Upvotes: 1

Related Questions