|
@@ -660,26 +660,12 @@ class AiMeasurement extends Api
|
|
|
if (isset($photos['back'])) {
|
|
|
$requestData['image3'] = $this->convertImageToBase64($photos['back']);
|
|
|
}
|
|
|
- // 记录请求日志(不包含图片数据)
|
|
|
- // $logData = [
|
|
|
- // 'url' => $apiUrl,
|
|
|
- // 'height' => $requestData['height'],
|
|
|
- // 'image_count' => count(array_filter([
|
|
|
- // isset($requestData['image1']),
|
|
|
- // isset($requestData['image2']),
|
|
|
- // isset($requestData['image3'])
|
|
|
- // ]))
|
|
|
- // ];
|
|
|
- // 记录请求日志(包含身高和图片base64数据的前50个字符)
|
|
|
+ // 记录完整的请求日志(包含完整的base64图片数据)
|
|
|
$logData = [
|
|
|
'url' => $apiUrl,
|
|
|
- 'height' => $heightValue . 'cm',
|
|
|
- 'image1' => isset($requestData['image1']) ? substr($requestData['image1'], 0, 50) . '...' : null,
|
|
|
- 'image2' => isset($requestData['image2']) ? substr($requestData['image2'], 0, 50) . '...' : null,
|
|
|
- 'image3' => isset($requestData['image3']) ? substr($requestData['image3'], 0, 50) . '...' : null,
|
|
|
- 'request_data_size' => strlen(json_encode($requestData)) . ' bytes'
|
|
|
+ 'request_data' => $requestData
|
|
|
];
|
|
|
- $this->writeLog('info', 'Calling third party AI service', $logData);
|
|
|
+ $this->writeLog('info', 'Calling third party AI service - Full Request', $logData);
|
|
|
|
|
|
// 发送POST请求
|
|
|
$ch = curl_init();
|
|
@@ -707,10 +693,10 @@ class AiMeasurement extends Api
|
|
|
throw new \Exception('请求第三方AI服务失败: ' . $error);
|
|
|
}
|
|
|
|
|
|
- $this->writeLog('info', 'Third party AI service response received', [
|
|
|
- 'response_size' => strlen($response) . ' bytes',
|
|
|
+ // 记录完整的响应日志
|
|
|
+ $this->writeLog('info', 'Third party AI service response - Full Response', [
|
|
|
'http_code' => $httpCode,
|
|
|
- 'response_preview' => substr($response, 0, 200) . '...'
|
|
|
+ 'response' => $response
|
|
|
]);
|
|
|
|
|
|
// 检查响应内容
|
|
@@ -720,16 +706,27 @@ class AiMeasurement extends Api
|
|
|
|
|
|
$result = json_decode($response, true);
|
|
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
|
+ // 记录JSON解析错误的完整信息
|
|
|
+ $this->writeLog('error', 'Third party AI service JSON decode error', [
|
|
|
+ 'http_code' => $httpCode,
|
|
|
+ 'json_error' => json_last_error_msg(),
|
|
|
+ 'raw_response' => $response
|
|
|
+ ]);
|
|
|
// 对于非200状态码,尝试返回原始响应内容作为错误信息
|
|
|
if ($httpCode !== 200) {
|
|
|
- throw new \Exception("第三方AI服务返回异常(HTTP {$httpCode}): " . substr($response, 0, 200));
|
|
|
+ throw new \Exception("第三方AI服务返回异常(HTTP {$httpCode}): " . $response);
|
|
|
} else {
|
|
|
- throw new \Exception('第三方AI服务返回数据格式错误');
|
|
|
+ throw new \Exception('第三方AI服务返回数据格式错误: ' . json_last_error_msg());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理各种HTTP错误状态,但先检查是否有有效的JSON响应
|
|
|
if ($httpCode !== 200) {
|
|
|
+ // 记录HTTP错误的完整信息
|
|
|
+ $this->writeLog('error', 'Third party AI service HTTP error', [
|
|
|
+ 'http_code' => $httpCode,
|
|
|
+ 'result' => $result
|
|
|
+ ]);
|
|
|
// 如果返回了JSON格式的错误信息,优先使用
|
|
|
if (isset($result['state']) && $result['state'] == 201) {
|
|
|
// 传参错误,通过processMeasurementData处理
|
|
@@ -748,15 +745,11 @@ class AiMeasurement extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 记录API响应信息
|
|
|
- // $responseLog = [
|
|
|
- // 'http_code' => $httpCode,
|
|
|
- // 'response_size' => strlen($response) . ' bytes',
|
|
|
- // 'has_body_size' => isset($result['body_size']),
|
|
|
- // 'body_size_fields' => isset($result['body_size']) ? array_keys($result['body_size']) : [],
|
|
|
- // 'response_preview' => substr($response, 0, 200) . '...'
|
|
|
- // ];
|
|
|
-
|
|
|
+ // 记录成功响应的完整解析数据
|
|
|
+ $this->writeLog('info', 'Third party AI service success - Parsed Result', [
|
|
|
+ 'http_code' => $httpCode,
|
|
|
+ 'result' => $result
|
|
|
+ ]);
|
|
|
|
|
|
// 处理返回的测量数据
|
|
|
// echo "<pre>";
|