yikart/AiToEarn · error · Error
获取三方平台数据失败
Error message
获取三方平台数据失败
What it means
getDashboard fetches douyin (抖音) platform dashboard data through douyinService.getDashboardFunc. If the service response reports success:false (third-party API failure, expired login cookie, or upstream error), the code throws a plain Error with the Chinese message '获取三方平台数据失败' (failed to get third-party platform data).
Source
Thrown at project/aitoearn-electron/electron/main/plat/platforms/douyin/index.ts:123
async getStatistics(account: AccountModel) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const accountInfo = await douyinService.getUserInfo(cookie);
return {
fansCount: accountInfo.fansCount,
workCount: 0, // TODO: 作品数量
};
}
async getDashboard(account: AccountModel, time: string[] = []) {
const res: DashboardData[] = [];
try {
const ret = await douyinService.getDashboardFunc(
account.loginCookie,
time[0],
time[1],
);
if (!ret.success) throw new Error('获取三方平台数据失败');
// console.log('@@@ret.data', ret.data)
for (const item of ret.data) {
res.push({
time: item.date,
fans: item.zhangfen,
read: item.bofang,
comment: item.pinglun,
like: item.dianzan,
forward: item.fenxiang,
collect: 0,
});
}
} catch (error) {
console.log('------ getDashboard wxSph ---', error);
}
return res.reverse();
}View on GitHub (pinned to d3aa8bea5b)
Solutions
- Re-authenticate the douyin account to refresh loginCookie
- Log ret payload on failure to see douyin's actual error and handle rate limits
- Validate/normalize the time range before calling getDashboardFunc
- Add a fallback/empty-result path so the dashboard UI degrades gracefully instead of throwing
Example fix
// before
if (!ret.success) throw new Error('获取三方平台数据失败');
// after
if (!ret.success || !Array.isArray(ret.data)) {
logger.warn('douyin dashboard failed', ret?.message);
return []; // graceful fallback
} Defensive patterns
Strategy: fallback
Validate before calling
if (!account.loginCookie || isCookieExpired(account.loginCookie)) {
throw new Error('Douyin login expired, please re-authenticate');
}
if (!Array.isArray(time) || time.length !== 2) {
throw new Error('Invalid dashboard time range');
} Type guard
function isDashboardResponse(r: unknown): r is { success: true; data: { date: string; zhangfen: number; bofang: number }[] } {
return !!r && typeof r === 'object' && (r as any).success === true && Array.isArray((r as any).data);
} Try / catch
try {
const data = await getDashboard(account, time);
} catch (e) {
if (e.message === '获取三方平台数据失败') {
logger.warn('Douyin dashboard unavailable, returning cached/empty data');
return cachedDashboard ?? [];
}
throw e;
} Prevention
- Refresh douyin loginCookie proactively and detect 401/cookie-expiry responses
- Log the third-party failure payload for diagnosis instead of a generic message
- Validate the time range before calling the upstream API
- Return empty/cached results so the dashboard degrades gracefully
When it happens
Trigger: douyinService returns { success: false } — typically because account.loginCookie is expired/invalid, the douyin open API rejected or rate-limited the request, or the time range parameters are invalid.
Common situations: User's douyin session cookie expired and needs re-login; douyin changed its API response shape; network/proxy failure reaching douyin; querying a time range with no data.
Related errors
- ChannelPlatformApiFailed
- ChannelPlatformResponseInvalid
- 服务器多次返回空数据,请检查网络连接或抖音服务器状态
- Failed to fetch image: ${response.status} ${response.statusT
- Relay uploadSign returned no uploadUrl: ${JSON.stringify(sig
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/5b5a36368facf608.
Report an issue: GitHub.