Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 抖音评论接口
牛文政78fc2c3dbd08
diff --git a/electron/main/reply/service.ts b/electron/main/reply/service.tsindex 48fe3b01..3c3dec53 100644--- a/electron/main/reply/service.ts+++ b/electron/main/reply/service.ts@@ -12,15 +12,25 @@ import { AccountModel } from '../../db/models/account';export class ReplyService {// 测试获取抖音作品列表async testGetDouyinList(account: AccountModel) {- const cookie: any = JSON.parse(account.loginCookie);- const res = await douyinService.getCreatorItems(- cookie,- '11111',- cookie.msToken,- );+ const cookie: Electron.Cookie[] = JSON.parse(account.loginCookie);- console.log(res);+ let msToken = '';+ for (let i = 0; i < cookie.length; i++) {+ if (cookie[i].name === 'msToken') {+ msToken = cookie[i].value;+ break;+ }+ }+ console.log('------ msToken ----', msToken);- return res;+ // 秒级时间戳+ const timestamp = Date.now();+ console.log('------ timestamp ----', timestamp);++ const res = await douyinService.getCreatorItems(cookie, timestamp + '', '');++ console.log('------ res ----', res);++ return 1;}}diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.tsindex ecb23531..a1525c78 100644--- a/electron/plat/douyin/index.ts+++ b/electron/plat/douyin/index.ts@@ -2145,7 +2145,7 @@ export class DouyinService {}/**- * 查询抖音的活动列表+ * 查询抖音的作品列表* @param cookie* @param msToken* @returns@@ -2182,6 +2182,27 @@ export class DouyinService {method: 'GET',});}++ // 作品的评论回复+ async getCreatorCommentReply(+ cookie: Electron.Cookie[],+ data: {+ comment_Id: string; // 空字符串, 直接回复+ item_id: string; // '@j/do779EQE//uctS8rzvvch6oCaTZCH0JqwsPqxpgahhkia+W5A7RJEoPQpq6PZl7wq9uxSqSWCjcIdbPzF8fQ==';+ text: string; //'哈哈哈';+ },+ msToken: string,+ a_bogus: string,+ ) {+ return await requestNet<DouyinCreatorCommentListResponse>({+ url: `https://creator.douyin.com/aweme/v1/creator/comment/reply/?msToken=${msToken}&a_bogus=${a_bogus}`,+ headers: {+ cookie: CookieToString(cookie),+ },+ method: 'POST',+ body: data,+ });+ }}// 导出服务实例diff --git a/src/icp/reply.ts b/src/icp/reply.tsindex 76f45a63..37d5f1d9 100644--- a/src/icp/reply.ts+++ b/src/icp/reply.ts@@ -9,7 +9,7 @@/*** 获取作品列表*/-export async function ipcCreatorList() {- const res = await window.ipcRenderer.invoke('ICP_CREATOR_LIST');+export async function ipcCreatorList(accountId: number) {+ const res = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId);return res;}diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsxindex 4778da9a..1586e9a5 100644--- a/src/views/reply/index.tsx+++ b/src/views/reply/index.tsx@@ -7,17 +7,27 @@*/import { ipcCreatorList } from '@/icp/reply';import { Button } from 'antd';-import { useState } from 'react';+import { useCallback, useState } from 'react';+import AccountSidebar from '../account/components/AccountSidebar';export default function Page() {const [activeTab, setActiveTab] = useState('car');+ const [activeAccountId, setActiveAccountId] = useState<number>(-1);async function getCreatorList() {- const res = await ipcCreatorList();+ const res = await ipcCreatorList(activeAccountId);console.log('----- res', res);}return (<div>+ <div>+ <AccountSidebar+ activeAccountId={activeAccountId}+ onAccountChange={useCallback((info) => {+ setActiveAccountId(info.id);+ }, [])}+ />+ </div><div><Button type="primary" onClick={getCreatorList}>获取列表