I can use the streaming API just fine when I don't include the count
parameter in filter()
call, but when I try to specify how many tweets from my history I want to receive, my stream object returns None
.
import tweepy
from tweepy.streaming import StreamListener, Stream
class Listener (StreamListener):
def on_status(self, status):
print '-' * 20
print status.text
return
def get_tweets(request):
# if request.is_ajax():
# All keys and secrets are declared here, but were removed for security reasons.
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
listener = Listener()
stream = Stream(auth, listener)
stream.filter(follow=("14739093",), count=-5)
I also tried the following, to see what it was returning.
>>> something = stream.filter(follow=("14739093",), count=-5)
>>> print something
None
Thanks for your help!
Stream.filter
always returnsNone
, its job is just to pass the data on to theStreamListener
.Your problem is that Twitter only allows the
count
parameter for certain "roles".This is the reason you're getting a
413
error when you try to use thecount
parameter -- you're on the "default access" role.