- I know that twitter released
apiv2 and that's a cause I got an error but I can't revise the code
- I'm aware that I have to use
streamingClient but I don't understand the concept
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
class TweetsListener(tweepy.Stream):
def __init__(self, csocket):
self.client_socket = csocket
def on_data(self, data):
try:
msg = json.loads( data )
print( msg['text'].encode('utf-8') )
self.client_socket.send( msg['text'].encode('utf-8') )
return True
except BaseException as e:
print("Error on_data: %s" % str(e))
return True
def on_error(self, status):
print(status)
return True
def sendData(c_socket):
twitter_stream=TweetsListener(
consumer_key, consumer_secret,
access_token, access_secret,
csocket=c_socket)
twitter_stream.filter(track=['football'])