ERROR while press at button

moustafa15564

20h

import RPi.GPIO as GPIO #Import GPIO library
import time #Import time library
import paho.mqtt.client as mqtt

user = ‘my username’
password = ‘my password’
client_id =‘my clientID’
server = ‘mqtt.mydevices.com
port = 1883

publish_0 = ‘v1/’+user+’/things/’+client_id+’/data/0’
publish_1 = ‘v1/’+user+’/things/’+client_id+’/data/1’
pulish_botao = ‘v1/’+user+’/things/’+client_id+’/data/3’
subscribe_botao= ‘v1/’+user+’/things/’+client_id+’/cmd/3’
PUB =‘v1/’+user+’/things/’+client_id+’/response’

def on_message(client, userdata, msg):
m = msg.topic.spilt(’/’)
p = msg.pyload.decode().spilt(’,’)
#print(‘m’)
#print(‘p’)
client.publish(publish_botao, p[0])

client = mqtt.Client(client_id)
client.username_pw_set(user , password)
client.connect(server,port)
client.on_message = on_message
client.subscribe(subscribe_botao)

client.loop_start()

for i in range(1, 10):
client.publish(publish_0, i)
client.publish(publish_1, i+2.1)
time.sleep(2)

this is my code its work good but when i click on the button on the dashboad it only loading and error in my code
is :
m = msg.topic.spilt(’/’)
AttributeError: ‘str’ object has no attribute ‘spilt’

# The callback for when a message is received from Cayenne.
def on_message(message):
    print("message received: " + str(message))
    # If there is an error processing the message return an error string, otherwise return nothing.
    if (message.channel == 4) and (message.value == "1"):
        print("button is pressed")