import time import jwt import requests def request_detail(): # 认证配置 access_token = "xxxxxxx" # 页面-配置管理-项目信息-APPKEY app_id = "xxxxxx" # 页面-配置管理-项目信息-APPID username = "xxxxx" # 请替换为企微ID(非企微用户使用用户名) # JWT Header jwt_headers = { "alg": "HS256", "typ": "JWT" } # 设置token过期时间 exp = int(time.time() + 120) # 业务参数 payload = { "exp": exp, } # 生成 JWT Token jwt_token = jwt.encode(payload=payload, key=access_token, algorithm='HS256', headers=jwt_headers) # 构造请求参数 # 记录的 ID,比如 url 为:https://perfsight.qq.com/singleUserDetail?id=1360168518203637760&os=pc&projId=3545&env=djI%3D&from=click 可通过 conditionalSearch 接口获取 performance_id 填入 # 从参数中取 id params = { 'username': username, 'Appid': app_id, 'token': jwt_token, 'Idstr': '1434927999485843456', } # 发送请求 headers = {'Content-Type': 'application/json'} # 国内环境 url = 'https://api.perfsight.qq.com/openapi/single/detail' # 海外环境(新加坡) # url = 'https://api.perfsight.wetest.net/openapi/single/detail' response = requests.post(url, json=params, headers=headers) print("Response:", response.json()) if __name__ == '__main__': request_detail()