{ "fName": "公告", "fIndex": [ { "id": 0, "name": "绿虎论坛" }, { "id": 199, "name": "公告", "parent_id": 0, "notopic": 0 } ], "tMeta": { "title": "[2023-05-11更新] 虎绿林API:JSON Page", "read_count": 156535, "uid": 1, "ctime": 1482562780, "mtime": 1683769055, "essence": 1, "locked": 0, "review": 0, "level": 0, "access": 0 }, "floorCount": 73, "currPage": 1, "maxPage": 4, "isLogin": null, "blockedReply": 0, "floorReverse": false, "canReply": false, "canLockReply": false, "canSink": false, "canSetEssence": false, "canMove": false, "tContents": [ { "uid": 1, "ctime": 1482562780, "mtime": 1683769055, "content": [ { "type": "markdown" }, { "type": "text", "value": "\r\n## 更新列表:\r\n[2023-05-11] 添加了" }, { "type": "mdpre", "data": "`?_time=1`" }, { "type": "text", "value": "参数,用于获取服务器的当前Unix时间戳,方便计算时间差(客户端本地时间可能不准,计算的时间差不能保证正确)。\r\n[2023-04-04] 添加了Cookie代偿机制,可在设置了" }, { "type": "mdpre", "data": "`_origin=*`" }, { "type": "text", "value": "的情况下通过头信息传递Cookie,具体见底部“Cookie代偿机制”一节。\r\n[2023-03-23] 添加了获取和设置消息已读状态的接口:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.104724.html" }, { "type": "text", "value": "\r\n[2023-03-22] 添加了UBB解析API:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.104715.html" }, { "type": "text", "value": "\r\n[2023-03-21] 新增了内信和" }, { "type": "mdpre", "data": "`@`" }, { "type": "text", "value": "消息统一跳转链接:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/link.ack.msg.996459.html" }, { "type": "text", "value": "\r\n 把996459换成消息的id即可,支持内信和" }, { "type": "at", "tag": "消息", "uid": 21502 }, { "type": "text", "value": ",会把消息设为已读,然后自动跳转到目标位置。\r\n[2023-03-19] 新增了内信和" }, { "type": "mdpre", "data": "`@`" }, { "type": "text", "value": "消息的WebSocket推送服务:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.104687.html" }, { "type": "text", "value": "\r\n[2021-11-11] 所有参数均可通过POST传递:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.101950.html" }, { "type": "text", "value": "\r\n[2021-11-04] 添加了表情列表接口:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/api.face.json" }, { "type": "text", "value": "\r\n[2021-09-16] 添加了全局参数" }, { "type": "mdpre", "data": "`_topic_summary=最大长度`" }, { "type": "text", "value": "来获取帖子内容摘要,可以在有" }, { "type": "mdpre", "data": "`topic_id`" }, { "type": "text", "value": "字段返回的页面获取帖子内容摘要(" }, { "type": "urlzh", "url": "https://hu60.cn/q.php/index.index.json?_topic_summary=100", "title": "演示" }, { "type": "text", "value": ")。\r\n\r\n[2021-09-09]\r\n* 所有全局参数(" }, { "type": "mdpre", "data": "`_uinfo`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_json`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_content`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_myself`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_origin`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_sid`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`_topic_summary`" }, { "type": "text", "value": ")现在都可以通过GET、POST和Header(" }, { "type": "mdpre", "data": "`x-uinfo`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-json`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-content`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-myself`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-origin`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-sid`" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`x-topic-summary`" }, { "type": "text", "value": ")方式传递。\r\n* 添加了用户搜索API:\r\n " }, { "type": "urlzh", "url": "https://hu60.cn/q.php/user.search.json?namePattern=老虎*&offset=0&limit=10&_uinfo=avatar", "title": null }, { "type": "text", "value": "\r\n\r\n[2021-02-04] 添加了全局参数" }, { "type": "mdpre", "data": "`_myself=1`" }, { "type": "text", "value": "和" }, { "type": "mdpre", "data": "`_myself=newMsg,newAtInfo,newChats`" }, { "type": "text", "value": ",可用于获取与用户自身相关的信息。\r\n* " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=1&_uinfo=name,avatar" }, { "type": "text", "value": "\r\n* " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=newMsg,newAtInfo,newChats&_uinfo=name,avatar,sign,contact" }, { "type": "text", "value": "\r\n\r\n[2021-01-19]\r\n* 帖子收藏现在有JSON Page版了:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.myfavorite.json" }, { "type": "text", "value": "\r\n* 向支持翻页的页面添加了" }, { "type": "mdpre", "data": "`currPage`" }, { "type": "text", "value": "字段用于指示当前页码(如 " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.forum.0.2.0.json" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`\"currPage\": 2, \"maxPage\": 2968`" }, { "type": "text", "value": ")\r\n* 向首页添加" }, { "type": "mdpre", "data": "`currPage`" }, { "type": "text", "value": "和" }, { "type": "mdpre", "data": "`hasNextPage`" }, { "type": "text", "value": "字段(" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json?p=2" }, { "type": "text", "value": " " }, { "type": "mdpre", "data": "`\"currPage\": 2, \"hasNextPage\": true`" }, { "type": "text", "value": ")\r\n\r\n[2021-01-14]\r\n* 为用户生成的内容添加了class标记,详见下面的“用户生成内容中的class标记”部分。\r\n* JSON Page 不对用户发言中的图片、链接等进行安全跳转(" }, { "type": "mdpre", "data": "`link.url.json?b64e=...`" }, { "type": "text", "value": "),而是直接返回原始链接。\r\n\r\n[2021-01-13] 添加了一个新的站点信息接口,返回网站名称、论坛名称、备案号等信息:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/site.info.json" }, { "type": "text", "value": "\r\n\r\n[2021-01-12] 今日更新如下:\r\n* 现在可以通过 " }, { "type": "mdpre", "data": "http://hu60.cn/q.php/user.stat.json" }, { "type": "text", "value": " 接口获取会显示在html版页面底部的聊天室新消息了。\r\n* 全局参数 _content 现在支持四种格式了:html、ubb、json和text,并且ubb和text类型在包括内信和at消息在内的所有地方都可安全使用。\r\n* 帖子编辑页面(" }, { "type": "mdpre", "data": "`bbs.edittopic.xxx.json`" }, { "type": "text", "value": ")的" }, { "type": "mdpre", "data": "`title`" }, { "type": "text", "value": "和" }, { "type": "mdpre", "data": "`content`" }, { "type": "text", "value": "字段现在不进行HTML实体转义(htmlspecialchars)了,如果要插入HTML中,请自行转义,以防XSS攻击。\r\n* 帖子页面添加GET参数" }, { "type": "mdpre", "data": "`floorReverse=0或1`" }, { "type": "text", "value": "用于调整楼层排序,如" }, { "type": "urlzh", "url": "https://hu60.cn/q.php/bbs.topic.82570.json?floorReverse=0", "title": "正序" }, { "type": "text", "value": "," }, { "type": "urlzh", "url": "https://hu60.cn/q.php/bbs.topic.82570.json?floorReverse=1", "title": "倒序" }, { "type": "text", "value": "\r\n* 现在聊天室删楼提醒已经和帖子删楼提醒统一了,可以正确给出json、ubb、text格式。\r\n* 添加了参数" }, { "type": "mdpre", "data": "`pageSize=分页大小`" }, { "type": "text", "value": ",可用于所有列表页面。\r\n\r\n[2019-07-04] 添加了“用户信息扩展”功能(演示:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_uinfo=name,avatar,sign,contact" }, { "type": "text", "value": " ),具体见下方描述。\r\n\r\n[2017-03-25] 添加了网页插件数据存储API,可供网页插件存储和查询自定义键值对:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.83603.html" }, { "type": "text", "value": "\r\n\r\n[2016-12-25] 全局参数 json 更名为 _json;添加了全局参数 _content=html|ubb|json 用于选择返回内容的格式。\r\n\r\n[2016-12-29] 添加了全局参数 _origin=\\*|域名,可支持浏览器中的跨站Ajax访问。为保证用户安全,跨站Ajax拒绝接受和设置任何Cookie。\r\n\r\n[2016-12-31] 修复在JSON页面发at消息,在html页面查看,点击链接跳转到JSON页面的问题。为解决问题,原url中的bid(html或json)用占位符“{$BID}”取代,并在显示时才替换成当前页面的bid。\r\n\r\n-----------------------------------------\r\n\r\n## 概述\r\n\r\n就在刚刚,虎绿林完成了整站的 JSON API 编写工作。\r\n\r\n为了减少工作量,以及保证 API 和网页的一致性,虎绿林用了一种独特的方式提供 API,可能除了虎绿林,没有人用同样的方法提供API了。\r\n\r\n我把这种方式称为 JSON Page(JSON页面),它实现的方法很简单,就是用虎绿林的主题切换功能,为网站写一个纯粹用JSON输出的主题。\r\n\r\n效果是这样的:\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json" }, { "type": "text", "value": "\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json" }, { "type": "text", "value": "\r\n\r\n把任何一个页面的后缀由 .html 改成 .json,就可以看到这个页面的 JSON 版本。\r\n几乎所有页面都提供了 JSON 版本,欢迎各位用 JSON 版本来做任何事。\r\n\r\n注意不是在" }, { "type": "mdpre", "data": "`.html`" }, { "type": "text", "value": "后面加" }, { "type": "mdpre", "data": "`.json`" }, { "type": "text", "value": ",而是把" }, { "type": "mdpre", "data": "`.html`" }, { "type": "text", "value": "改成" }, { "type": "mdpre", "data": "`.json`" }, { "type": "text", "value": "。比如首页的HTML版:\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.html" }, { "type": "text", "value": "\r\n首页的JSON版:\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json" }, { "type": "text", "value": "\r\n\r\nJSON 版本的交互方式和网页是一样的:\r\n比如翻页,网页是改变URL,JSON版本也是改变URL。\r\n再比如发言,网页是 POST 提交,JSON版本也是一样,提交的参数也和网页相同,唯一的区别是提交的页面的后缀改成 .json。\r\n\r\nJSON版本可能会有错误,如果遇到问题,请及时在这个帖子反馈。\r\n\r\n---------------------------\r\n\r\n## JSON Page 专用参数:\r\n\r\n* 通过POST传递所有参数,包括" }, { "type": "mdpre", "data": "`PATHINFO`" }, { "type": "text", "value": "部分\r\n 详见:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.101950.html" }, { "type": "text", "value": "\r\n\r\n* 获取当前时间(" }, { "type": "mdpre", "data": "`_time=1`" }, { "type": "text", "value": ")\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/msg.index.@.no.json?_time=1" }, { "type": "text", "value": "\r\n 任意页面均可用,返回结果会多一个" }, { "type": "mdpre", "data": "`_time`" }, { "type": "text", "value": "字段,值为服务器当前Unix时间戳,\r\n 方便计算时间差(客户端本地时间可能不准,计算的时间差不能保证正确)。\r\n \r\n\r\n* 楼层排序(" }, { "type": "mdpre", "data": "`floorReverse=0|1`" }, { "type": "text", "value": ")\r\n 正序:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?floorReverse=0" }, { "type": "text", "value": "\r\n 倒序:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?floorReverse=1" }, { "type": "text", "value": "\r\n\r\n* 分页大小(" }, { "type": "mdpre", "data": "`pageSize=分页大小`" }, { "type": "text", "value": ")\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?pageSize=100" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/addin.chat.%E5%85%AC%E5%85%B1%E8%81%8A%E5%A4%A9%E5%AE%A4.json?pageSize=3" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/msg.index.inbox.all.json?pageSize=50" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json?pageSize=5" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.forum.json?pageSize=10" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.forum.0.1.json?pageSize=100" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.html?keywords=&username=%E8%80%81%E8%99%8E%E4%BC%9A%E6%B8%B8%E6%B3%B3&pageSize=5" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.html?keywords=&username=%E8%80%81%E8%99%8E%E4%BC%9A%E6%B8%B8%E6%B3%B3&searchType=reply&pageSize=30" }, { "type": "text", "value": "\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/user.stat.json?pageSize=20" }, { "type": "text", "value": "\r\n\r\n 论坛首页(bbs.forum.json,展示每个版块的前N个帖子)和底部聊天室新消息(user.stat.json)的分页大小上限是100,其他页面上限是1000。\r\n\r\n---------------------------\r\n\r\n## JSON Page 专用页面:\r\n\r\n* 获取和设置消息已读状态的接口:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.104724.html" }, { "type": "text", "value": "\r\n\r\n* 内信和" }, { "type": "mdpre", "data": "`@`" }, { "type": "text", "value": "消息统一跳转链接:\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/link.ack.msg.996459.html" }, { "type": "text", "value": "\r\n 把996459换成消息的id即可,支持内信和" }, { "type": "at", "tag": "消息", "uid": 21502 }, { "type": "text", "value": ",会把消息设为已读,然后自动跳转到目标位置。\r\n\r\n* 查看登录状态、内信和@" }, { "type": "empty" }, { "type": "text", "value": "信息条数,还可以获取会显示在html版页面底部的聊天室新消息。该页面只有json版。\r\n " }, { "type": "mdpre", "data": "http://hu60.cn/q.php/user.stat.json" }, { "type": "text", "value": "\r\n\r\n* 站点信息页面,返回网站名称、论坛名称、备案号等信息。该页面只有json版。\r\n " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/site.info.json" }, { "type": "text", "value": "\r\n\r\n* 用户搜索API(该页面只有json版):\r\n [" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/user.search.json?namePattern=" }, { "type": "text", "value": "老虎*&offset=0&limit=10&_uinfo=avatar](" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/user.search.json?namePattern=" }, { "type": "text", "value": "老虎*&offset=0&limit=10&_uinfo=avatar)\r\n " }, { "type": "mdpre", "data": "`namePattern`" }, { "type": "text", "value": "参数可用的模式:\r\n " }, { "type": "mdpre", "data": "`*`" }, { "type": "text", "value": " 匹配任意字符\r\n " }, { "type": "mdpre", "data": "`?`" }, { "type": "text", "value": " 匹配单个字符\r\n " }, { "type": "mdpre", "data": "`用户名前缀*`" }, { "type": "text", "value": " 搜索包含特定前缀的用户名\r\n " }, { "type": "mdpre", "data": "`*部分用户名*`" }, { "type": "text", "value": " 搜索包含特定字符的用户名\r\n " }, { "type": "mdpre", "data": "`?????`" }, { "type": "text", "value": " 搜索特定长度的用户名\r\n " }, { "type": "mdpre", "data": "`完整用户名`" }, { "type": "text", "value": " 精确搜索特定用户\r\n\r\n* 发言中可用的表情列表:" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/api.face.json" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## UBB解析API:\r\n\r\n提供以下功能:\r\n* UBB文本转JSON数组\r\n* UBB文本或JSON数组转纯文本\r\n* UBB文本或JSON数组转HTML\r\n* JSON数组转UBB文本\r\n\r\n详见 " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.104715.html" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## 数据存储API:\r\n\r\n可供网页插件存储和查询自定义键值对,详见 " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.83603.html" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## 七牛云文件上传API:\r\n\r\n可上传文件到虎绿林的七牛云存储库,供发帖使用。详见 " }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.89896.html" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## JSON压缩(注意,参数名由 json 变成了 _json):\r\n\r\n用 _json=compact 参数可以得到压缩后的 JSON 结果\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json?_json=compact" }, { "type": "text", "value": "\r\n\r\n如果你想要把所有返回的数组都变成对象,可以用 _json=object\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json?_json=object" }, { "type": "text", "value": "\r\n\r\n这两个参数可以一起用,_json=compact,object\r\n\r\n参数可通过GET、POST、Header(" }, { "type": "mdpre", "data": "`x-json`" }, { "type": "text", "value": ")方式传递:\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\ncurl https://hu60.cn/q.php/index.index.json?_json=compact\r\ncurl --data '_json=compact' https://hu60.cn/q.php/index.index.json\r\ncurl --header 'x-json: compact' https://hu60.cn/q.php/index.index.json\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## 获取帖子内容摘要\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/index.index.json?_topic_summary=100" }, { "type": "text", "value": "\r\n\r\n100为摘要最大长度,超出则截断并在末尾添加“…”。\r\n\r\n在所有会返回" }, { "type": "mdpre", "data": "`topic_id`" }, { "type": "text", "value": "的页面均可用。\r\n\r\n---------------------------\r\n\r\n## 用户信息扩展:\r\n\r\n可以用于任何返回值中包含" }, { "type": "mdpre", "data": "`uid`" }, { "type": "text", "value": "或者" }, { "type": "mdpre", "data": "`***uid`" }, { "type": "text", "value": "(如" }, { "type": "mdpre", "data": "`byuid`" }, { "type": "text", "value": "、" }, { "type": "mdpre", "data": "`touid`" }, { "type": "text", "value": ")的页面。\r\n添加URL参数" }, { "type": "mdpre", "data": "`_uinfo=name,avatar,sign,contact`" }, { "type": "text", "value": "(逗号分隔,可以删掉不需要的项目),返回值中便会多出如下成员:\r\n" }, { "type": "mdpre", "data": "`_u_name`" }, { "type": "text", "value": "," }, { "type": "mdpre", "data": "`_u_avatar`" }, { "type": "text", "value": "," }, { "type": "mdpre", "data": "`_u_signature`" }, { "type": "text", "value": "," }, { "type": "mdpre", "data": "`_u_contact`" }, { "type": "text", "value": "。\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_uinfo=name,avatar,sign,contact" }, { "type": "text", "value": "\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n...\r\n\"uid\": 1,\r\n\"_u_name\": \"老虎会游泳\",\r\n\"_u_avatar\": \"http://file.hu60.cn/avatar/1.jpg?1557592687\",\r\n\"_u_signature\": \"你好,这里是虎绿林。\",\r\n\"_u_contact\": \"QQ 905172616 & 18502433620 & hu60.cn@gmail.com & N/A\"\r\n...\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n如果是" }, { "type": "mdpre", "data": "`***uid`" }, { "type": "text", "value": ",则" }, { "type": "mdpre", "data": "`***`" }, { "type": "text", "value": "位于字段开头,如:\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/msg.index.json?_uinfo=name,avatar,sign,contact" }, { "type": "text", "value": "\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n...\r\n\"touid\": 1,\r\n\"byuid\": 841,\r\n\"to_u_name\": \"老虎会游泳\",\r\n\"to_u_avatar\": \"http://file.hu60.cn/avatar/1.jpg?1557592687\",\r\n\"to_u_signature\": \"你好,这里是虎绿林。\",\r\n\"to_u_contact\": \"QQ 905172616 & 18502433620 & hu60.cn@gmail.com & N/A\",\r\n\"by_u_name\": \"000\",\r\n\"by_u_avatar\": \"http://file.hu60.cn/avatar/841.jpg\",\r\n\"by_u_signature\": \"安静的PHPer\",\r\n\"by_u_contact\": \"to7@foxmail.com\"\r\n...\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n参数可通过GET、POST、Header(" }, { "type": "mdpre", "data": "`x-uinfo`" }, { "type": "text", "value": ")方式传递:\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\ncurl https://hu60.cn/q.php/index.index.json?_uinfo=name,avatar,sign,contact\r\ncurl --data '_uinfo=name,avatar,sign,contact' https://hu60.cn/q.php/index.index.json\r\ncurl --header 'x-uinfo: name,avatar,sign,contact' https://hu60.cn/q.php/index.index.json\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## 获取用户自身信息:\r\n\r\n可以用于任何页面,可以与上面的“用户信息扩展”结合使用。\r\n\r\n添加URL参数" }, { "type": "mdpre", "data": "`_myself=1`" }, { "type": "text", "value": "或者" }, { "type": "mdpre", "data": "`_myself=newMsg,newAtInfo,newChats`" }, { "type": "text", "value": "即可。\r\n\r\n为了防止其他信息干扰,我专门选了个几乎没有其他信息的页面演示该功能。该功能实际上可用于任何页面,添加的" }, { "type": "mdpre", "data": "`_myself`" }, { "type": "text", "value": "字段会出现在JSON底部。\r\n\r\n参数可通过GET、POST、Header(" }, { "type": "mdpre", "data": "`x-myself`" }, { "type": "text", "value": ")方式传递:\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\ncurl https://hu60.cn/q.php/index.index.json?_myself=1\r\ncurl --data '_myself=1' https://hu60.cn/q.php/index.index.json\r\ncurl --header 'x-myself: 1' https://hu60.cn/q.php/index.index.json\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n### 仅获取uid\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=1" }, { "type": "text", "value": "\r\n\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n{\r\n ...\r\n \"_myself\": {\r\n \"isLogin\": true,\r\n \"uid\": 1\r\n }\r\n}\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n### 获取uid,昵称,头像\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=1&_uinfo=name,avatar" }, { "type": "text", "value": "\r\n\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n{\r\n ...\r\n \"_myself\": {\r\n \"isLogin\": true,\r\n \"uid\": 1,\r\n \"_u_name\": \"老虎会游泳\",\r\n \"_u_avatar\": \"https://file.hu60.cn/avatar/1.jpg?1588915503\"\r\n }\r\n}\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n### 获取uid,昵称,头像,新内信条数,新At消息条数\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=newMsg,newAtInfo&_uinfo=name,avatar" }, { "type": "text", "value": "\r\n\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n{\r\n ...\r\n \"_myself\": {\r\n \"isLogin\": true,\r\n \"uid\": 1,\r\n \"newMsg\": 0,\r\n \"newAtInfo\": 1,\r\n \"_u_name\": \"老虎会游泳\",\r\n \"_u_avatar\": \"https://file.hu60.cn/avatar/1.jpg?1588915503\"\r\n }\r\n}\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n### 获取uid,新内信条数,新At消息条数,聊天室最新发言\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.search.json?_myself=newMsg,newAtInfo,newChats" }, { "type": "text", "value": "\r\n\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\n \"_myself\": {\r\n \"isLogin\": true,\r\n \"uid\": 1,\r\n \"newMsg\": 0,\r\n \"newAtInfo\": 1,\r\n \"newChats\": [\r\n {\r\n \"id\": 19038,\r\n \"room\": \"公共聊天室\",\r\n \"lid\": 8882,\r\n \"uid\": 21479,\r\n \"uname\": \"我是教官\",\r\n \"content\": \"发言内容省略\",\r\n \"time\": 1612450046,\r\n \"hidden\": 0,\r\n \"review\": 0\r\n },\r\n {\r\n \"id\": 19002,\r\n \"room\": \"更换聊天室\",\r\n \"lid\": 6,\r\n \"uid\": 1,\r\n \"uname\": \"老虎会游泳\",\r\n \"content\": \"发言内容省略\",\r\n \"time\": 1612443635,\r\n \"hidden\": 0,\r\n \"review\": 0\r\n },\r\n {\r\n \"id\": 18918,\r\n \"room\": \"老虎会游泳\",\r\n \"lid\": 100,\r\n \"uid\": 5372,\r\n \"uname\": \"穴儿\",\r\n \"content\": \"发言内容省略\",\r\n \"time\": 1612411015,\r\n \"hidden\": 0,\r\n \"review\": 0\r\n }\r\n ]\r\n }\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n---------------------------\r\n\r\n## 返回内容格式选择:\r\n\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_content=html" }, { "type": "text", "value": "\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_content=json" }, { "type": "text", "value": "\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_content=ubb" }, { "type": "text", "value": "\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/bbs.topic.82570.json?_content=text" }, { "type": "text", "value": "\r\n\r\n参数可通过GET、POST、Header(" }, { "type": "mdpre", "data": "`x-content`" }, { "type": "text", "value": ")方式传递:\r\n" }, { "type": "mdcode", "lang": "", "data": "\r\ncurl https://hu60.cn/q.php/bbs.topic.82570.json?_content=ubb\r\ncurl --data '_content=ubb' https://hu60.cn/q.php/bbs.topic.82570.json\r\ncurl --header 'x-content: ubb' https://hu60.cn/q.php/bbs.topic.82570.json\r\n", "quote": "```" }, { "type": "text", "value": "\r\n\r\n这个参数可以用来改变包含UBB的内容的格式。\r\n支持四种格式:html、json、ubb、text,如果没有这个参数,默认是html。\r\n\r\n注意:ubb和text都没有进行HTML实体转义(htmlspecialchars),如果要插入HTML中,请自行转义,以防XSS攻击。\r\n\r\njson格式是帖子内容存储在数据库中的格式,其基本形式为:\r\n\r\n1. 每个UBB标记存储为一个 JSON 对象,其中包含 type 属性,记录了UBB的类型。每个类型都有各自不同的其他属性,记录了UBB的实际数据。纯文本的UBB类型为text。\r\n2. 帖子的所有内容从前往后依次排列构成一个 JSON 数组。\r\n\r\n具体的解码方法参考:" }, { "type": "mdpre", "data": "https://github.com/hu60t/hu60wap6/blob/master/src/class/ubbdisplay.php" }, { "type": "text", "value": "\r\n\r\n此外,2021年1月12日更新后,对内信和at消息使用ubb和text类型就都是安全的了。管理员删除提醒、管理员编辑提醒、管理员沉帖提醒都有了对应的结果,但是结果均为纯文本内容(因为这些提醒没有对应的UBB)。\r\n\r\n~~不过,还是建议使用json类型来获取at消息的机器可读数据~~(不再建议了,因为" }, { "type": "mdpre", "data": "`msg`" }, { "type": "text", "value": "类型不再是纯文本,而是UBB JSON,解析起来非常复杂。目前建议的解析方式详见" }, { "type": "urlzh", "url": "https://hu60.cn/q.php/bbs.topic.82570.html?floor=67#67", "title": "67楼" }, { "type": "text", "value": "。)\r\n~~at消息的json数据非常容易解析~~(不再容易了,详见" }, { "type": "urlzh", "url": "https://hu60.cn/q.php/bbs.topic.82570.html?floor=65#65", "title": "65楼" }, { "type": "text", "value": "):\r\n" }, { "type": "mdpre", "data": "https://hu60.cn/q.php/msg.index.@.json?_content=json" }, { "type": "text", "value": "\r\n" }, { "type": "code", "lang": "js", "data": "\r\n\"content\": [\r\n {\r\n \"type\": \"atMsg\",\r\n \"uid\": 15591,\r\n \"pos\": \"帖子“虎绿林API:Json Page”的回复中\",\r\n \"url\": \"bbs.topic.82570.{$BID}\",\r\n \"msg\": \"@老虎会游泳,多此一举\",\r\n \"len\": 60\r\n }\r\n]\r\n" }, { "type": "text", "value": "\r\n注意URL中的“{$BID}”,它应该被替换为当前页面的bid(如html或json)。\r\n\r\n备注:2021年1月12日更新后,聊天室删楼提醒已经和帖子删楼提醒统一了,可以正确给出json、ubb、text格式。\r\n\r\n---------------------------\r\n\r\n## 用户生成内容中的" }, { "type": "mdpre", "data": "`class`" }, { "type": "text", "value": "标记\r\n\r\n为了方便处理用户生成内容中的链接等元素,JSON Page在返回html格式的帖子、聊天等内容时会给用户生成的某些元素打上对应的class标记,具体如下:\r\n\r\n* " }, { "type": "mdpre", "data": "`userblocked`" }, { "type": "text", "value": " 用户被禁言\r\n\r\n 如:" }, { "type": "mdpre", "data": "`
phpinfo();
`"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userlink`"
},
{
"type": "text",
"value": " 用户贴出来的链接\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "`一只谷歌鸟`"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`usertarget`"
},
{
"type": "text",
"value": " 用户生成的锚链接\r\n 如:"
},
{
"type": "mdpre",
"data": "``"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userimg`"
},
{
"type": "text",
"value": " 用户贴出来的图片\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "``"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userimglink`"
},
{
"type": "text",
"value": " 为用户图片自动生成的链接(用于点击查看大图)\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "``"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userthumb`"
},
{
"type": "text",
"value": " 用户缩略图\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "``"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userthumblink`"
},
{
"type": "text",
"value": " 为用户缩略图自动生成的链接(用于点击查看大图)\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "``"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`uservideosite`"
},
{
"type": "text",
"value": " 自动生成的视频网站链接,在用户视频播放窗口的上方\r\n\r\n 请参考"
},
{
"type": "mdpre",
"data": "`《视频:视频网站播放地址》`"
},
{
"type": "text",
"value": "UBB的效果\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`useraudiosite`"
},
{
"type": "text",
"value": " 自动生成的音频网站链接,在用户音频播放窗口的上方\r\n\r\n 请参考"
},
{
"type": "mdpre",
"data": "`《音频:音频网站播放地址》`"
},
{
"type": "text",
"value": "UBB的效果\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`uservideolink`"
},
{
"type": "text",
"value": " 自动生成的视频流链接,在用户视频播放窗口的上方\r\n\r\n 请参考"
},
{
"type": "mdpre",
"data": "`《视频流:视频下载地址》`"
},
{
"type": "text",
"value": "UBB的效果\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`useraudiolink`"
},
{
"type": "text",
"value": " 自动生成的音频流链接,在用户音频播放窗口的上方\r\n\r\n 请参考"
},
{
"type": "mdpre",
"data": "`《音频流:音频下载地址》`"
},
{
"type": "text",
"value": "UBB的效果\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`userbattlenet`"
},
{
"type": "text",
"value": " 用户发的暴雪战网链接(过时)\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "`老虎会游泳@安格博达`"
},
{
"type": "text",
"value": "\r\n\r\n* "
},
{
"type": "mdpre",
"data": "`usermath`"
},
{
"type": "text",
"value": " 用户编写的公式\r\n\r\n 如:"
},
{
"type": "mdpre",
"data": "`