diff --git a/docs/en/social-media.md b/docs/en/social-media.md index 1bea61f39..2d26ba650 100644 --- a/docs/en/social-media.md +++ b/docs/en/social-media.md @@ -34,10 +34,14 @@ pageClass: routes ::: tip -Official user RSS: http://**:username**.lofter.com/rss +~~Official user RSS: http://**:username**.lofter.com/rss~~ ::: +### User + + + ### Tag diff --git a/docs/social-media.md b/docs/social-media.md index 1409d589b..bf48ca4bc 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -294,10 +294,14 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 ::: tip 提示 -官方提供了用户主页 RSS: http://**:username**.lofter.com/rss +~~官方提供了用户主页 RSS: http://**:username**.lofter.com/rss~~ ::: +### 用户 + + + ### 话题(标签) diff --git a/lib/router.js b/lib/router.js index dd861aac4..fa5002490 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1979,6 +1979,7 @@ router.get('/taptap/review/:id/:order?', require('./routes/taptap/review')); // lofter router.get('/lofter/tag/:name/:type?', require('./routes/lofter/tag')); +router.get('/lofter/user/:username', require('./routes/lofter/posts')); // 米坛社区表盘 router.get('/watchface/:watch_type?/:list_type?', require('./routes/watchface/update')); diff --git a/lib/routes/lofter/posts.js b/lib/routes/lofter/posts.js new file mode 100644 index 000000000..b1472e29d --- /dev/null +++ b/lib/routes/lofter/posts.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const blogdomain = `${ctx.params.username}.lofter.com`; + const response = await got({ + method: 'post', + url: `http://api.lofter.com/v2.0/blogHomePage.api?product=lofter-iphone-6.8.2`, + headers: { + Host: 'api.lofter.com', + 'User-Agent': 'LOFTER/6.8.2 (iPhone; iOS 13.4; Scale/2.00)', + }, + form: { + blogdomain: blogdomain, + checkpwd: '1', + following: '0', + limit: '15', + method: 'getPostLists', + needgetpoststat: '1', + offset: '0', + postdigestnew: '1', + supportposttypes: '1,2,3,4,5,6', + }, + }); + const data = response.data.response.posts; + ctx.state.data = { + title: `${ctx.params.username}.lofter.com`, + link: blogdomain, + description: `${ctx.params.username}.lofter.com`, + item: data.map((item) => { + let content = item.post.content; + const title = item.post.title || item.post.noticeLinkTitle; + const photos = JSON.parse(item.post.photoLinks || `[]`); + const images = []; + photos.forEach((photo) => { + images.push(`

`); + }); + content = `${content}${images.join('')}`; + return { + title: title, + description: content, + pubDate: new Date(item.post.publishTime).toUTCString(), + link: item.post.blogPageUrl, + guid: item.post.blogPageUrl, + author: item.post.blogInfo.blogNickName, + }; + }), + }; +};