const { callSocialGateway } = require('./voc-gateway'); const VOC_SOCIAL_API_ROOT = 'https://server.fmode.cn/api/voc-social'; const XIAOHONGSHU_APP_BASE_URL = `${VOC_SOCIAL_API_ROOT}/xiaohongshu/app`; class XiaohongshuApi { constructor(options = {}) { this.baseUrl = options.baseUrl || process.env.XIAOHONGSHU_API_BASE_URL || XIAOHONGSHU_APP_BASE_URL; this.token = options.token; this.fallbackToken = options.fallbackToken || ''; this.headers = options.headers || {}; } request(proxyPath, query) { return callSocialGateway({ proxyPath, method: 'GET', query, token: this.token, fallbackToken: this.fallbackToken, baseUrl: this.baseUrl, headers: this.headers }); } searchNotes({ keyword, page = 1, sort = 'popularity_descending', noteType = '_0' }) { return this.request('search_notes', { keyword, page, sort, note_type: noteType }); } getNoteDetail({ noteId }) { return this.request('get_note_info', { note_id: noteId }); } getNoteComments({ noteId, cursor = '' }) { return this.request('get_note_comments', { note_id: noteId, cursor }); } } module.exports = { VOC_SOCIAL_API_ROOT, XIAOHONGSHU_APP_BASE_URL, XiaohongshuApi };