#!/usr/bin/env php initialize(); echo "✅ 应用初始化成功!\n\n"; try { $haichaoJst = \app\haichao\HaichaoJstServices::getServices(); if (empty($spu)) { echo "测试 getProductListStand 方法...\n\n"; $result = $haichaoJst->getProductListStand(); echo "✅ API调用成功!\n\n"; echo "返回数据类型: " . gettype($result) . "\n"; if (is_array($result)) { echo "顶层键值:\n"; foreach (array_keys($result) as $key) { echo " - {$key}\n"; } if (isset($result['datas']) && is_array($result['datas'])) { echo "\n📦 datas数组包含 " . count($result['datas']) . " 个元素\n\n"; if (!empty($result['datas'])) { echo "第一个元素:\n"; print_r($result['datas'][0]); } else { echo "⚠️ datas数组为空\n"; } } else if (isset($result[0])) { echo "\n📦 第一个元素:\n"; print_r($result[0]); } else { echo "\n完整返回:\n"; print_r($result); } } else { echo "\n完整返回:\n"; print_r($result); } echo "\n\n"; echo "完整JSON:\n"; echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); echo "\n"; } else { echo "测试 getProductListKuan 方法...\n\n"; echo "SPU: " . $spu . "\n\n"; $result = $haichaoJst->getProductListKuan($spu); echo "✅ API调用成功!\n\n"; echo "完整JSON:\n"; echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); echo "\n"; } echo "\n========================================\n"; echo "测试完成\n"; echo "========================================\n"; } catch (\Throwable $e) { echo "\n❌ 发生错误!\n"; echo "错误信息: " . $e->getMessage() . "\n"; echo "错误文件: " . $e->getFile() . ":" . $e->getLine() . "\n"; echo "\n堆栈跟踪:\n" . $e->getTraceAsString() . "\n"; exit(1); }