Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 小红书评论接口
牛文政395c43af2c46
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.tsindex c8a01fdc..7b57eae0 100644--- a/electron/plat/xiaohongshu/index.ts+++ b/electron/plat/xiaohongshu/index.ts@@ -10,6 +10,8 @@ import {IXHSLocationResponse,IXHSTopicsResponse,IXHSWorks,+ XhsCommentListResponse,+ XhsCommentPostResponse,XiaohongshuApiResponse,} from './xiaohongshu.type';@@ -1410,15 +1412,64 @@ export class XiaohongshuService {noteId: string,cursor?: number,) {- return await requestNet<XiaohongshuApiResponse>({- url: `https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?note_id=${noteId}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=AB9FJ4Lt0GzHqwzKCWh2glQja0HkO-sc0zNChTPhFvwGo%3D`,+ const url = `https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?note_id=${noteId}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=AB9FJ4Lt0GzHqwzKCWh2glQpU_HdfsMIJ5MuRM8aB9Xvo%3D`;+ const reverseRes: any = await this.getReverseResult({+ url,+ a1: CookieToString(cookie),+ });++ return await requestNet<XhsCommentListResponse>({+ url,headers: {cookie: CookieToString(cookie),Referer: this.loginUrl,origin: this.loginUrl,+ 'X-S': reverseRes['X-s'],+ 'X-T': reverseRes['X-t'],+ userAgent:+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',+ },+ method: 'GET',+ });+ }++ /**+ * 评论作品+ * @param noteId+ * @param content+ * @param targetCommentId // 回复的评论ID+ * @returns+ */+ async commentPost(+ cookie: Electron.Cookie[],+ noteId: string,+ content: string,+ targetCommentId?: string, // "67d4145300000000190210ba"+ ) {+ const url = `https://edith.xiaohongshu.com/api/sns/web/v1/comment/post`;+ const reverseRes: any = await this.getReverseResult({+ url,+ a1: CookieToString(cookie),+ });++ return await requestNet<XhsCommentPostResponse>({+ url,+ headers: {+ cookie: CookieToString(cookie),+ Referer: this.loginUrl,+ origin: this.loginUrl,+ 'X-S': reverseRes['X-s'],+ 'X-T': reverseRes['X-t'],+ userAgent:+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',},method: 'POST',- body: {},+ body: {+ note_id: noteId,+ content,+ target_comment_id: targetCommentId,+ at_users: [],+ },});}}diff --git a/electron/plat/xiaohongshu/xiaohongshu.type.ts b/electron/plat/xiaohongshu/xiaohongshu.type.tsindex 96ea556e..8684f024 100644--- a/electron/plat/xiaohongshu/xiaohongshu.type.ts+++ b/electron/plat/xiaohongshu/xiaohongshu.type.ts@@ -115,3 +115,104 @@ export type IXHSTopicsResponse = CommonResponse<TopicsData>;// 地点列表返回值export type IXHSLocationResponse = CommonResponse<LocationData>;++// 评论列表返回值+export type XhsCommentListResponse = {+ code: number; // 0;+ success: boolean; // true;+ msg: string; // '成功';+ data: {+ user_id: string; // '6433a78b000000000e01d2bf';+ comments: [+ {+ note_id: string; // '64477a32000000000800db6b';+ liked: boolean; // false;+ user_info: {+ user_id: string; // '6433a78b000000000e01d2bf';+ nickname: string; // '快乐的不快乐';+ image: string; // 'https://sns-avatar-qc.xhscdn.com/avatar/64469a41b2b360267e424ade.jpg?imageView2/2/w/120/format/jpg';+ xsec_token: string; // 'ABwV2_E6v08_HB53bZla7rsC7W5ZvWpAmbowx4iPyhhTQ=';+ };+ sub_comment_has_more: boolean; // false;+ content: string; // '哈哈哈';+ like_count: string; // '0';+ ip_location: string; // '河北';+ id: string; // '67d028670000000019034092';+ at_users: [];+ show_tags: string[]; // ['is_author'];+ create_time: number; // 1741695080000;+ sub_comment_count: string; // '1';+ sub_comments: {+ status: number; // 0;+ content: string; // '嘿嘿';+ at_users: [];+ liked: false;+ create_time: number; // 1741695086000;+ ip_location: string; // '河北';+ id: string; // '67d0286d0000000019018ff5';+ like_count: string; // '0';+ user_info: {+ user_id: string; // '6433a78b000000000e01d2bf';+ nickname: string; // '快乐的不快乐';+ image: string; // 'https://sns-avatar-qc.xhscdn.com/avatar/64469a41b2b360267e424ade.jpg?imageView2/2/w/120/format/jpg';+ xsec_token: string; // 'ABwV2_E6v08_HB53bZla7rsC7W5ZvWpAmbowx4iPyhhTQ=';+ };+ show_tags: string[]; // ['is_author'];+ target_comment: {+ id: string; // '67d028670000000019034092';+ user_info: {+ image: string; // 'https://sns-avatar-qc.xhscdn.com/avatar/64469a41b2b360267e424ade.jpg?imageView2/2/w/120/format/jpg';+ xsec_token: string; // 'ABwV2_E6v08_HB53bZla7rsC7W5ZvWpAmbowx4iPyhhTQ=';+ user_id: string; // '6433a78b000000000e01d2bf';+ nickname: string; // '快乐的不快乐';+ };+ };+ note_id: string; // '64477a32000000000800db6b';+ }[];+ sub_comment_cursor: string; // '67d0286d0000000019018ff5';+ status: number; // 0;+ },+ ];+ cursor: string; // '67d028670000000019034092';+ has_more: boolean; // false;+ time: number; // 1741951532993;+ xsec_token: string; // 'ABwV2_E6v08_HB53bZla7rsC7W5ZvWpAmbowx4iPyhhTQ=';+ };+};++// 评论作品+export type XhsCommentPostResponse = {+ success: boolean; // true;+ msg: string; // '成功';+ data: {+ comment: {+ show_tags: string[]; // ['is_author'];+ create_time: number; // 1741952083568;+ at_users: string[]; // [];+ liked: boolean; // false;+ user_info: {+ nickname: string; // '快乐的不快乐';+ image: string; // 'https://sns-avatar-qc.xhscdn.com/avatar/64469a41b2b360267e424ade.jpg?imageView2/2/w/120/format/jpg';+ user_id: string; // '6433a78b000000000e01d2bf';+ };+ content: string; // '背景不错';+ like_count: string; // '0';+ ip_location: string; // '河北';+ id: string; // '67d4145300000000190210ba';+ note_id: string; // '64477a32000000000800db6b';+ status: number; // 2;+ target_comment?: {+ // 被回复的评论信息+ id: string; // '67d4145300000000190210ba';+ user_info: {+ user_id: string; // '6433a78b000000000e01d2bf';+ nickname: string; // '快乐的不快乐';+ image: string; // 'https://sns-avatar-qc.xhscdn.com/avatar/64469a41b2b360267e424ade.jpg?imageView2/2/w/120/format/jpg';+ };+ };+ };+ time: number; // 1741952083585;+ toast: string; // '评论已发布'; // 你的回复已发布+ };+ code: number; // 0;+};diff --git a/package.json b/package.jsonindex 12a16dc0..96b28db5 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "att",- "version": "0.1.2",+ "version": "0.1.3","main": "dist-electron/main/index.js","description": "艺咖 win打包使用管理员的终端","author": "艺咖",