user3235069
user3235069

Reputation: 21

TWEEPY STREAM: my timeline tweets

I need to catch the tweets I recieve in my timeline from the people I follow.

The code I have is:

*import sys  
import tweepy 
from tweepy import Stream 
from tweepy.streaming import StreamListener

CONSUMER_KEY = 'fgdg'  
CONSUMER_SECRET = 'fdgdfgdf' 
ACCESS_KEY = 'fgdfgd'  
ACCESS_SECRET = 'dfgdfgdfg' 

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)  
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)  
api = tweepy.API(auth)

class listener(StreamListener):

    def on_data(self, data):
        print data
        return True
    def on_error(self, status):
        print status

twitterStream = Stream(auth, listener()) 
twitterStream.filter(track=["order"])*

But this give me the PUBLIC STREAM. I only want MY TIMELINE STREAM

Upvotes: 2

Views: 2204

Answers (2)

Gtr_py
Gtr_py

Reputation: 3759

use

twitterStream.userstream(encoding='utf8')

instead of

twitterStream.filter(track=["order"])*

Upvotes: 2

Aaron Hill
Aaron Hill

Reputation: 3196

Instead of the track method of the Stream object, you can use the userstream method of the Stream object. This returns only the data that appears on a user's personal timeline. To further limit the tweets returned, you might want to pass _with='user' to userstream. This limits the returned events to events only concerning the authenticated user, not their followings.

Upvotes: 6

Related Questions