diff --git a/lib/routes/weibo/timeline.js b/lib/routes/weibo/timeline.js index ed91e75c4..63ee62727 100644 --- a/lib/routes/weibo/timeline.js +++ b/lib/routes/weibo/timeline.js @@ -8,6 +8,16 @@ module.exports = async (ctx) => { if (token) { const response = await got.get(`https://api.weibo.com/2/statuses/home_timeline.json?access_token=${token}&count=100&feature=${feature}`); + // 检查token失效 + if (response.data.error !== undefined) { + const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0' } = config.weibo; + + ctx.status = 302; + ctx.set({ + 'Cache-Control': 'no-cache', + }); + ctx.redirect(`https://api.weibo.com/oauth2/authorize?client_id=${app_key}&redirect_uri=${redirect_url}`); + } // 获取所有表情 const weiboEmotion = await ctx.cache.tryGet('weiboEmotion', async () => { const tmpEmotionList = {};