import network
import time
import urequests
print("Conectando al wifi", end="")
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '') # Nombre de la red con contraseña
token = "EAAJgBPuuAZCcBO5gjhmhxyusTtyl9NH84oN2hzXQANq5D2ZCRW0ceUW50BXDpA1Xju61eKtFZBRjNE2ZAHwWZCOEj8N10FWPKZAu8vLKDUClqTKcBggTZC4Lho4u05rmNhhTy70DJsZAGpCgZBDvSZCjS7aKnIV8NJMgU0T8QpxmMMTmMXxnEOoQxU72DdVZBtJL5xj"
x="temperatura es de 50"
msj = {
"messaging_product": "whatsapp",
"to": "573005019233",
"type": "text",
"text": {
"body": x
}
}
url = "https://graph.facebook.com/v17.0/167984166389118/messages"
# Definir el encabezado con el token de acceso
headers = {"Authorization": "Bearer " + token, "Content-Type": "application/json"}
while True:
if not sta_if.isconnected():
print(".", end="")
time.sleep(0.5)
if sta_if.isconnected():
#print("Conectado!")
# Realizar la solicitud GET a la URL con el encabezado del token de acceso
response = urequests.post(url, json=msj, headers={"Authorization": f"Bearer {token}"})
print(response.text)
response.close()
time.sleep(3) # Esperar 60 segundos antes de realizar la siguiente solicitud