Skip to content

Commit

Permalink
fix(route)(weibo/user): outdated API method (DIYgod#9446)
Browse files Browse the repository at this point in the history
Signed-off-by: Rongrong <[email protected]>
  • Loading branch information
Rongronggg9 authored and RikkaBlue committed Apr 9, 2022
1 parent 594cd54 commit 37b16bd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/routes/weibo/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,33 @@ module.exports = async (ctx) => {
}

const containerData = await ctx.cache.tryGet(
`weibo:user:profile:${uid}`,
`weibo:user:index:${uid}`,
async () => {
const _r = await got({
method: 'get',
url: `https://m.weibo.cn/profile/info?uid=${uid}`,
url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}`,
headers: {
Referer: 'https://m.weibo.cn/',
Referer: `https://m.weibo.cn/u/${uid}`,
'MWeibo-Pwa': 1,
'X-Requested-With': 'XMLHttpRequest',
},
});
return _r.data;
},
config.cache.routeExpire,
false
);
const name = containerData.data.user.screen_name;
const description = containerData.data.user.description;
const profileImageUrl = containerData.data.user.profile_image_url;
const containerId = containerData.data.more.match(/\d+/)[0];
const name = containerData.data.userInfo.screen_name;
const description = containerData.data.userInfo.description;
const profileImageUrl = containerData.data.userInfo.profile_image_url;
const containerId = containerData.data.tabsInfo.tabs.filter((item) => item.tab_type === 'weibo')[0].containerid;

const cards = await ctx.cache.tryGet(
`weibo:user:cards:${uid}:${containerId}`,
async () => {
const _r = await got({
method: 'get',
url: `https://m.weibo.cn/api/container/getIndex?containerid=${containerId}`,
url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}&containerid=${containerId}`,
headers: {
Referer: `https://m.weibo.cn/u/${uid}`,
'MWeibo-Pwa': 1,
Expand Down

0 comments on commit 37b16bd

Please sign in to comment.