帖子

列出全部主题帖

GET /api/discussions
{
  "links": {
    "first": "https://bbs.arktoolbox.jamsg.cn/api/discussions",
    "next": "https://bbs.arktoolbox.jamsg.cn/api/discussions?page%5Boffset%5D=20"
  },
  "data": [
    {
      "type": "discussions",
      "id": "227",
      "attributes": {
        "title": "出师表",
        "slug": "227-chu-shi-biao",
        "commentCount": 10,
        "participantCount": 3,
        "createdAt": "0227-01-01T00:10:30+08:00",
        "lastPostedAt": "0227-01-05T00:10:30+08:00",
        "lastPostNumber": 10,
        "canReply": true,
        "canRename": true,
        "canDelete": true,
        "canHide": true,
        "isHidden": true,
        "hiddenAt": "0227-01-01T00:10:30+08:00",
        "lastReadAt": "0227-01-01T00:10:30+08:00",
        "lastReadPostNumber": 2,
        "isApproved": true,
        "canTag": true,
        "isLocked": false,
        "canLock": true,
        "isSticky": false,
        "canSticky": true,
        "canMerge": true,
        "subscription": null
      },
      "relationships": {
        "user": {
          "data": {
            "type": "users",
            "id": "1"
          }
        },
        "lastPostedUser": {
          "data": {
            "type": "users",
            "id": "64"
          }
        },
        "tags": {
          "data": [
            {
              "type": "tags",
              "id": "3"
            }
          ]
        },
        "firstPost": {
          "data": {
            "type": "posts",
            "id": "668"
          }
        }
      }
    },
    {
      "type": "discussions",
      "id": "234",
      "attributes": {
        // [...]
      },
      "relationships": {
        // [...]
      }
    },
    // [...] 更多主题
  ],
  "included": [
    {
      "type": "users",
      "id": "1",
      "attributes": {
        "username": "Zhugeliang",
        "displayName": "诸葛亮",
        "avatarUrl": null,
        "slug": "1"
      }
    },
    {
      "type": "users",
      "id": "64",
      "attributes": {
        "username": "Flarum",
        "displayName": "Flarum",
        "avatarUrl": "https://flarum.tld/assets/avatars/Z4hEncw0ndVqZ8be.png",
        "slug": "64"
      }
    },
    {
      "type": "tags",
      "id": "3",
      "attributes": {
        "name": "欢迎",
        "description": "在这里发送一些有趣的玩意儿",
        "slug": "welcome",
        "color": "#888",
        "backgroundUrl": null,
        "backgroundMode": null,
        "icon": "fas fa-bullhorn",
        "discussionCount": 30,
        "position": 1,
        "defaultSort": null,
        "isChild": false,
        "isHidden": false,
        "lastPostedAt": "2022-01-05T10:20:30+00:00",
        "canStartDiscussion": true,
        "canAddToDiscussion": true,
        "isRestricted": false
      }
    },
    {
      "type": "posts",
      "id": "668",
      "attributes": {
        "number": 1,
        "createdAt": "2022-01-01T10:20:30+00:00",
        "contentType": "comment",
        "contentHtml": "<p>你好,世界!</p>"
      }
    },
    // [...] 其他包含内容
  ]
}

发布主题

POST /api/discussions
{
  "data":{
    "type": "discussions",
    "attributes": {
      "title": "这里是标题",
      "content": "你好,世界!"
    },
    "relationships": {
      "tags": {
        "data": [
          {
            "type": "tags",
            "id": "1"
          }
        ]
      }
    }
  }
}

服务器响应含有新主题的 ID:

{
  "data": {
    "type": "discussions",
    "id": "42",
    "attributes": {
      "title": "这里是标题",
      "slug": "42-gu-ding-lian-jie",
      "commentCount": 1
      // [...] 其他属性
    },
    "relationships": {
      "posts": {
        "data": [
          {
            "type": "posts",
            "id": "58"
          }
        ]
      },
      "user": {
        "data": {
          "type": "users",
          "id": "1"
        }
      },
      // [...] 其他关联内容
    }
  },
  "included":[
    {
      "type": "posts",
      "id": "38",
      "attributes": {
        "number": 1,
        "contentType": "comment",
        "contentHtml": "\u003Cp\u003E你好,世界!\u003C\/p\u003E"
        // [...] 其他属性
      }
    }
    // [...] 其他包含内容
  ]
}

Last updated

Was this helpful?