You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MEXC Global API v3测试订单请求报400错误求助

求助:MEXC Global API v3 POST /order/test 测试订单请求报错

尝试调用MEXC Global API v3的POST /order/test接口发起测试订单请求,始终报错,以下是相关信息:

1. Curl请求信息

返回内容为{"code":500,"msg":"Internal error"},HTTP状态码为400,请求详情如下:

string(35) "{"code":500,"msg":"Internal error"}" array(37) { ["url"]=> string(201) "https://api.mexc.com/api/v3/order/test?timestamp=1700891018.787&symbol=SLTUSDT&side=BUY&type=LIMIT&quantity=0.0002&price=30000&signature=MY_SIGNATUR" ["content_type"]=> string(16) "application/json" ["http_code"]=> int(400) ["header_size"]=> int(469) ["request_size"]=> int(582) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.286157) ["namelookup_time"]=> float(0.000274) ["connect_time"]=> float(0.004934) ["pretransfer_time"]=> float(0.026281) ["size_upload"]=> float(84) ["size_download"]=> float(35) ["speed_download"]=> float(122) ["speed_upload"]=> float(293) ["download_content_length"]=> float(35) ["upload_content_length"]=> float(84) ["starttransfer_time"]=> float(0.286132) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(13) "SERVER_IP" ["certinfo"]=> array(0) { } ["primary_port"]=> int(443) ["local_ip"]=> string(13) "MY_IP" ["local_port"]=> int(48306) ["http_version"]=> int(2) ["protocol"]=> int(2) ["ssl_verifyresult"]=> int(0) ["scheme"]=> string(5) "HTTPS" ["appconnect_time_us"]=> int(28448) ["connect_time_us"]=> int(5206) ["namelookup_time_us"]=> int(485) ["pretransfer_time_us"]=> int(28484) ["redirect_time_us"]=> int(0) ["starttransfer_time_us"]=> int(287498) ["total_time_us"]=> int(287522) }

2. 所用PHP代码

$symbol = 'SLTUSDT';
$serverTime = 1656298742; //Unix-Timestamp in Nano-sek
$secretKey = 'MY_SECRET_KEY';
$timestamp = $serverTime / 1000 + 1000;
$method = 'POST';
$path = '%2Fapi%2Fv3%2Forder%2Ftest'; //URL_encoded path-string

// Query string for a limit order
$params = [
    'symbol' => $symbol,
    'side' => 'BUY',
    'type' => 'LIMIT',
    'quantity' => '0.0002',
    'price' => '30000'
];

// Generate the signature
$stringToSign = 'timestamp=' . $timestamp . '&method=' . $method . '&path=' . $path;
$signature = hash_hmac('sha256', $stringToSign, $secretKey);

// Set the headers
$headers = [
    'Content-Type: application/json',
    'X-MEXC-APIKEY: MY_API_KEY',
    'Authorization: Bearer MY_API_SECRET',
    'X-MEXC-API-Signature: ' . $signature,
    'X-MEXC-API-Timestamp: ' . $timestamp,
    'recvWindow: 50000'
];

// Generate the URL
//$url = 'https://api.mexc.com/api/v3/order/test?symbol=' . $symbol;
$url='https://api.mexc.com/api/v3/order/test?timestamp='.$timestamp.'&symbol='.$symbol.'&side='.$params['side'].'&type='.$params['type']
.'&quantity='.$params['quantity'].'&price='.$params['price'].'&signature='.$signature;

// Make the API call
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params)); // For a limit order
$response = curl_exec($curl);
curl_close($curl);

echo $response;

3. AI分析结果

该请求返回400 Bad Request错误,属于客户端错误,可能原因包括请求语法错误、请求消息帧无效、请求路由异常等,并给出了验证请求语法、检查消息帧等排查建议。


内容的提问来源于stack exchange,提问作者Simon Deboy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 11:05:23