Reputation: 21
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
Reputation: 3759
use
twitterStream.userstream(encoding='utf8')
instead of
twitterStream.filter(track=["order"])*
Upvotes: 2
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