| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // 探测 Sorftime ProductReviewsQuery 的响应字段名(生产环境 VOC skill 在用它)
- const https = require('https');
- function httpJson(opts, body = null) {
- return new Promise((res) => {
- const req = https.request({ ...opts, timeout: 45000 }, (x) => {
- const chunks = [];
- x.on('data', (c) => chunks.push(c));
- x.on('end', () => {
- const b = Buffer.concat(chunks).toString('utf-8');
- let j = null;
- try { j = JSON.parse(b); } catch (e) {}
- res({ status: x.statusCode, body: b, json: j });
- });
- });
- req.on('error', (e) => res({ status: 0, err: e.message }));
- req.on('timeout', () => { req.destroy(); res({ status: 0, err: 'timeout' }); });
- if (body) req.write(body);
- req.end();
- });
- }
- async function sorftime(apiPath, body) {
- const bs = JSON.stringify({ path: apiPath, method: 'POST', body, query: { domain: 1 } });
- return httpJson({
- hostname: 'server-msq.fmode.cn',
- path: '/api/sorftime/forward',
- method: 'POST',
- headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(bs) },
- }, bs);
- }
- async function main() {
- const asin = 'B079JX3FMC'; // Bronson from smoke test
- console.log('Probing ProductReviewsQuery for', asin);
- const r = await sorftime('/api/ProductReviewsQuery', { ASIN: asin });
- console.log('status:', r.status);
- if (r.json) {
- const d = r.json?.Data ?? r.json?.data ?? r.json;
- console.log('top keys:', Object.keys(d || {}));
- console.log('full response (first 1200 chars):');
- console.log(JSON.stringify(d, null, 2).slice(0, 1200));
- } else {
- console.log('body:', (r.body || '').slice(0, 600));
- }
- }
- main();
|