Get value (0 or 1) from ubidots to control led status on raspberry

Hi! I would Get value from switch variable on ubidots to control led status on raspberry.

I wrote this:

from ubidots import ApiClient
import RPi.GPIO as GPIO

api=ApiClient(token="8eFc5Plu0zTOKEN")
variable=api.get_variable("5782b5977625426a9d647175")

last_value=variable.get_values(1)

if last_value==1:
      GPIO.output(18,True)