Stream encountered HTTP error: 403. I'm a beginner at pyspark and python, I can't revise the code

Viewed 37
  1. I know that twitter released apiv2 and that's a cause I got an error but I can't revise the code
  2. 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'])


0 Answers
Related