import time import jwt import requests # 认证配置 access_token = "xxxxxxx" # 页面-配置管理-项目信息-APPKEY app_id = "xxxxxx" # 页面-配置管理-项目信息-APPID username = "xxxxx" # 企微ID # JWT Header jwt_headers = { "alg": "HS256", "typ": "JWT" } # 业务参数 payload = { "version": [], "stime": "2025-10-23 00:00:00", # 开始时间 "etime": "2025-10-24 23:59:59", # 结束时间 "platform": "1", # 平台:0(Android), 1(iOS), 5(PC) "userName": username, "size": 1, # 查询数量,不超过10000 "timeSortField": 2, # 查询时间标准,1是场景上传时间,2是按场景开始时间 "requestid": username + "_conditionalSearch_openapi", "source": 1, # 环境:国内 1,国际 2 # "userIdList": ["2631767013043271769"] # 用户ID列表(可选) } # 生成 JWT Token jwt_token = jwt.encode(payload=payload, key=access_token, algorithm='HS256', headers=jwt_headers) # 构造请求参数 params = { 'username': username, 'app_id': app_id, 'token': jwt_token } # 发送请求 headers = {'Content-Type': 'application/json'} # 国内环境 # url = 'https://api.perfsight.qq.com/openapi/single/conditionalSearch' # 海外环境(新加坡) url = 'https://api.perfsight.wetest.net/openapi/single/conditionalSearch' print("Token:", jwt_token) response = requests.post(url, json=params, headers=headers) response_data = response.json() print("Response:", response_data)