Files
auto_cursor_online/test_api.py
2025-03-31 09:55:54 +08:00

71 lines
2.0 KiB
Python

import requests
import json
# API URL
api_url = "https://cursorapi.nosqli.com/admin/api.AutoCursor/commonadd"
# 测试数据 - 尝试不同字段格式
test_data1 = [
{
"email": "test1@example.com",
"email_password": "test_password",
"cursor_email": "test1@example.com",
"cursor_password": "test_cursor_password",
"cookie": "test_cookie",
"token": "test_token"
}
]
test_data2 = [
{
"email": "test2@example.com",
"password": "test_password", # 使用password而不是email_password
"cursor_email": "test2@example.com",
"cursor_password": "test_cursor_password",
"cookie": "test_cookie",
"token": "test_token"
}
]
test_data3 = [
{
"email": "test3@example.com",
"email_password": "test_password",
"password": "test_password", # 同时提供password和email_password
"cursor_email": "test3@example.com",
"cursor_password": "test_cursor_password",
"cookie": "test_cookie",
"token": "test_token"
}
]
# 请求头
headers = {
"Content-Type": "application/json"
}
# 测试函数
def test_api(data, description):
print(f"\n测试 {description}:")
print(f"发送数据: {json.dumps(data, ensure_ascii=False)}")
try:
response = requests.post(api_url, headers=headers, json=data)
print(f"状态码: {response.status_code}")
if response.status_code == 200:
try:
result = response.json()
print(f"响应内容: {json.dumps(result, ensure_ascii=False, indent=2)}")
except json.JSONDecodeError:
print(f"非JSON响应: {response.text[:200]}...")
else:
print(f"请求失败: {response.text[:200]}...")
except Exception as e:
print(f"请求异常: {str(e)}")
# 执行测试
if __name__ == "__main__":
test_api(test_data1, "使用email_password字段")
test_api(test_data2, "使用password字段")
test_api(test_data3, "同时提供password和email_password字段")