Python websocket - error: NameError("name 'opcode' is not defined",)

Hi,

I am trying to create a function in Python call API authorize function and seems always give me the same error:
NameError("name 'opcode' is not defined",)
Am I missing some setting???

Code as below, any idea???

import websocket
import json

def on_message(ws, message):
print('authorise: %s' % message)

def on_open(ws):
json_data = json.dumps({'authorize':'XXXXXXXXX'})
ws.send(json_data)

def on_error(ws, error):
print('authorise: %s' % error)

def toAuthorise ():
apiUrl = "wss://ws.binaryws.com/websockets/v3"
ws = websocket.WebSocketApp(apiUrl, on_message = on_message, on_open = on_open, on_error = on_error)
ws.run_forever()

Comments

Sign In or Register to comment.