almeira-web/scripts/check_evolution_state.py

24 lines
712 B
Python

import urllib.request
import json
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
EVOLUTION_API_URL = "https://evolution.almeira.com.co"
EVOLUTION_API_KEY = "EE49029EEB85-4568-8F81-C9FDFC6E2943"
INSTANCE_NAME = "AutomataAlmeira"
TARGET_PHONE = "573167455877"
# Check instance state
try:
req = urllib.request.Request(
f"{EVOLUTION_API_URL}/instance/connectionState/{INSTANCE_NAME}",
headers={"apikey": EVOLUTION_API_KEY}
)
with urllib.request.urlopen(req, context=ctx, timeout=10) as r:
print("AutomataAlmeira connectionState:", r.read().decode('utf-8'))
except Exception as e:
print("Error connectionState:", e)