← 返回首页

🔌 API 对接配置

第三方网站集成配置信息

第一步:复制接口配置

接口地址
https://tuchuang.wcym.cc//api/upload.php
请求方式
POST
参数名称
image
认证方式
URL参数: ?api_key=你的密钥
⚠️ API Key 获取方式:
1. 注册账号 → 2. 登录 → 3. 进入用户中心 → 4. 创建新密钥

第二步:集成代码示例

const formData = new FormData(); formData.append('image', fileInput.files[0]); const apiKey = 'tk_your_api_key_here'; // 替换为你的API Key const apiUrl = 'https://tuchuang.wcym.cc//api/upload.php?api_key=' + apiKey; fetch(apiUrl, { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { if (data.success) { console.log('Base64:', data.data.base64); console.log('URL:', data.data.url); // 使用返回的Base64显示图片 document.getElementById('preview').src = data.data.base64; } else { console.error('上传失败:', data.message); } }) .catch(error => console.error('错误:', error));
curl -X POST \ -F "image=@/path/to/image.jpg" \ "https://tuchuang.wcym.cc//api/upload.php?api_key=tk_your_api_key_here"
import requests url = 'https://tuchuang.wcym.cc//api/upload.php' params = {'api_key': 'tk_your_api_key_here'} files = {'image': open('image.jpg', 'rb')} response = requests.post(url, params=params, files=files) result = response.json() if result['success']: print('Base64:', result['data']['base64']) print('URL:', result['data']['url'])
$ch = curl_init(); $apiKey = 'tk_your_api_key_here'; $url = 'https://tuchuang.wcym.cc//api/upload.php?api_key=' . $apiKey; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'image' => new CURLFile('/path/to/image.jpg') ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo "Base64: " . $data['data']['base64'];

第三步:处理返回数据

字段 类型 说明
data.base64 string 完整Base64编码(可直接用于<img src="...">
data.url string 临时访问URL(120秒有效)
data.filename string 服务器文件名
data.size integer 文件大小(字节)
data.mime_type string 图片MIME类型
⚠️ 重要提示:
• URL只有 120秒 有效期,如需长期使用请保存 base64 字段
• 最大文件大小:10MB
• 支持格式:JPG, PNG, GIF, WebP, BMP, SVG
成功响应示例:
{ "success": true, "message": "上传成功", "data": { "base64": "data:image/jpeg;base64,/9j/4AAQSkZJRg...", "url": "http://example.com/access.php?file=xxx.jpg&expires=...", "filename": "abc123.jpg", "size": 102400, "mime_type": "image/jpeg" } }

🧪 在线测试

使用在线测试工具验证配置是否正确:

前往 API 测试页面 →