From 4a87758b1602292002e0e48eefab96c816f1fb7a Mon Sep 17 00:00:00 2001 From: jingrow Date: Sat, 2 Aug 2025 14:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96domain=5Fwest.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/domain_west.py | 90 --------------------------------------- 1 file changed, 90 deletions(-) diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index ae5b6c1..fcde610 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -1427,93 +1427,3 @@ def test_create_domain_owner_with_template(): except Exception as e: jingrow.log_error("测试API异常", str(e)) return {"status": "Error", "message": f"测试API调用失败: {str(e)}"} - - """硬编码参数测试创建域名模板""" - try: - import requests - import hashlib - import time - import json - from urllib.parse import urlencode - - # 硬编码的API配置 - username = "yanyukuang" # 请替换为实际的用户名 - password = "Jingrow@20250731" # 请替换为实际的密码 - api_base_url = "https://api.west.cn/api/v2" - - # 生成认证token - current_time = int(time.time() * 1000) - token_string = f"{username}{password}{current_time}" - token = hashlib.md5(token_string.encode('utf-8')).hexdigest() - - # 构建公共参数 - common_params = { - 'username': username, - 'time': str(current_time), - 'token': token, - } - - # 直接在template_data中硬编码所有数据 - template_data = { - 'act': 'auditsub', - 'c_regtype': 'I', - 'fullname': '张强', - 'c_co': 'CN', - 'cocode': '+86', - 'c_st_m': '广东省', - 'c_ct_m': '广州市', - 'c_dt_m': '花都区', - 'c_adr_m': '狮岭镇龙头市场二栋', - 'c_pc': '510000', - 'c_ph_type': '0', - 'c_ph': '13926598569', - 'c_em': '13926598569@139.com', - 'c_ln': 'Zhang', - 'c_fn': 'Qiang', - 'c_st': 'GD', - 'c_ct': 'guangzhou', - 'c_adr': 'Shi Ling Zhen Long Tou Shi Chang 2 Dong' - } - - # 构建URL - param_string = urlencode(common_params) - url = f"{api_base_url}/audit/?{param_string}" - - headers = { - 'Content-Type': 'application/x-www-form-urlencoded' - } - - # 发送请求 - jingrow.log_error("硬编码测试API发送", f"URL: {url}") - jingrow.log_error("硬编码测试API数据", f"模板数据: {template_data}") - - # 使用urlencode编码POST数据,指定GBK编码 - encoded_data = urlencode(template_data, encoding='gbk').encode('gbk') - - response = requests.post(url, data=encoded_data, headers=headers, timeout=30) - response.raise_for_status() - - try: - result = response.json() - except json.JSONDecodeError: - jingrow.log_error("硬编码测试API响应解析失败", response_text=response.text) - result = {"status": "error", "message": "无法解析API响应"} - - jingrow.log_error("硬编码测试API结果", f"结果: {result}") - - if result.get('result') == 200: - c_sysid = result.get('data', {}).get('c_sysid') - return { - "status": "success", - "message": "域名模板创建成功", - "data": { - "c_sysid": c_sysid - } - } - else: - error_msg = result.get('msg', result.get('message', '未知错误')) - return {"status": "error", "message": f"创建域名模板失败: {error_msg}"} - - except Exception as e: - jingrow.log_error("硬编码测试API异常", str(e)) - return {"status": "error", "message": f"测试API调用失败: {str(e)}"} \ No newline at end of file