This commit is contained in:
chengxl
2025-09-02 09:43:45 +08:00
parent 0fa43f178d
commit b3d4f7b33b

View File

@@ -52,12 +52,12 @@ class WechatMaterial
$response = $oAiarticle->uploadMaterial($data); $response = $oAiarticle->uploadMaterial($data);
// 验证API响应 // 验证API响应
if (empty($response)) { if (empty($response)) {
throw new RuntimeException("OpenAI API返回空结果"); throw new \RuntimeException("OpenAI API返回空结果");
} }
// 检查JSON解析错误 // 检查JSON解析错误
$aResult = json_decode($response, true); $aResult = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
throw new RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}"); throw new \RuntimeException("解析OpenAI响应失败: " . json_last_error_msg() . " | 原始响应: {$response}");
} }
$sMsg = empty($aResult['msg']) ? '上传素材失败' : $aResult['msg']; $sMsg = empty($aResult['msg']) ? '上传素材失败' : $aResult['msg'];