I am new to tweepy. And tried to implement an api which can listen the new tweets for a @mention or screen name.
tweets = api.user_timeline(screen_name=username)
But it is not listening the new tweets. Could you please help me to understand how it can be implemented so that whenever a tweet comes with '@mention'. the api should listen immediately
def on_data( self, status ):
print("Entered on_data()")
print(status.text, flush = True)
return True
...
user = api.verify_credentials()
# this is just for getting user. without this also connection can be established
if user:
print(user.id)
print('started')
twitter_stream=Stream(auth,StdOutListener())
print('Stream created...')
twitter_stream.filter(follow=[user.id_str], is_async=True)