UNPKG

@liuliang520500/pdd-sdk-new

Version:

拼多多开放平台 SDK,支持多多进宝商品推广、订单查询等接口

34 lines (33 loc) 1.18 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const index_js_1 = require("../index.js"); const dotenv_1 = __importDefault(require("dotenv")); // 加载环境变量 dotenv_1.default.config(); // 初始化客户端 const client = new index_js_1.PddClient({ clientId: process.env.PDD_CLIENT_ID, clientSecret: process.env.PDD_CLIENT_SECRET, accessToken: process.env.PDD_SESSION_TOKEN }); async function testGoodsDetail() { try { const params = { type: 'pdd.ddk.oauth.goods.detail', goods_sign: 'E9j2AdzphfZiwIxFwvTel54m3Q953ZdY_JQcAb6DCCX', pid: process.env.PDD_PID, }; const response = await client.execute(params); if (response.goods_detail_response) { const goods = response.goods_detail_response.goods_details[0]; console.log(`商品 ${goods.goods_name} (ID: ${goods.goods_id}) 查询成功`); } } catch (error) { console.error('查询失败:', error); } } testGoodsDetail();