#!/usr/bin/env python3 import os import requests from requests.auth import HTTPBasicAuth HDR = { "User-Agent": "Mozilla/5.0 (compatible; AZA-WooDiagnostic/1.0)", "Accept": "application/json", } def main() -> None: base = (os.environ.get("AZA_WOOCOMMERCE_URL") or "").strip().rstrip("/") auth = HTTPBasicAuth( os.environ.get("AZA_WOOCOMMERCE_CONSUMER_KEY") or "", os.environ.get("AZA_WOOCOMMERCE_CONSUMER_SECRET") or "", ) paths = [ "/wp-json/wc/v3", "/wp-json/wc/v3/orders/1447", "/wp-json/wc/v3/subscriptions/1448", "/wp-json/wc/v3/subscriptions?per_page=1", ] for p in paths: r = requests.get(base + p, auth=auth, headers=HDR, timeout=15) print("path", p) print(" http", r.status_code, "ct", (r.headers.get("content-type") or "")[:40]) try: j = r.json() if isinstance(j, dict): print(" wp_code", j.get("code")) if "id" in j: print(" id_field", j.get("id")) elif isinstance(j, list): print(" list_len", len(j)) except Exception: print(" not_json") if __name__ == "__main__": main()