资讯专栏INFORMATION COLUMN

记录下Flarum论坛API设计

YorkChen / 1341人阅读

摘要:

Using the API

Every Flarum forum exposes a publicly-accessible JSON API that can read and write forum data. It conforms to the JSON-API 1.0 specification.

Authentication

The API uses token-based authentication. Some endpoints do not require authentication. You can retrieve a token from the /api/token endpoint:

POST /api/token HTTP/1.1

{
    "identification": "Toby",
    "password": "pass7word"
}

HTTP/1.1 200 OK

{
    "token": "YACub2KLfe8mfmHPcUKtt6t2SMJOGPXnZbqhc3nX",
    "userId": "1"
}

You can then pass the token in an Authorization header in subsequent requests:

GET /api/forum HTTP/1.1
Authorization: Token YACub2KLfe8mfmHPcUKtt6t2SMJOGPXnZbqhc3nX

Forum

GET /api/forum - get information about the forum, including groups and tags
PATCH /api/forum - update forum config

Discussions

GET /api/discussions - get all discussions (sort is -time by default)
filter[q] - filter by username/gambits
POST /api/discussions - create a new discussion
GET /api/discussions/:id - get a discussion by ID
PATCH /api/discussions/:id - update a discussion
DELETE /api/discussions/:id - delete a discussion

Posts

GET /api/posts - get all posts
filter[discussion] - filter by discussion ID
filter[user] - filter by user ID
filter[number] - filter by number (position within the discussion)
filter[type] - filter by post type
POST /api/posts - create a new post
GET /api/posts/:id - get a post by ID
PATCH /api/posts/:id - update a post
DELETE /api/posts/:id - delete a post

Users

GET /api/users - get all users
filter[q] - filter by username/gambits
POST /api/users - register a new user
GET /api/users/:idOrUsername - get a user by ID or username
PATCH /api/users/:id - update a user
DELETE /api/users/:id - delete a user
POST /api/users/:id/avatar - upload a user avatar
DELETE /api/users/:id/avatar - delete a user avatar

Groups

GET /api/groups - get all groups
POST /api/groups - create a new group
PATCH /api/groups/:id - update a group
DELETE /api/groups/:id - delete a group

Notifications

GET /api/notifications - get all notifications
PATCH /api/notifications/:id - mark a notification as read

Tags

POST /api/tags - create a new tag
PATCH /api/tags/:id - update a tag
DELETE /api/tags/:id - delete a tag

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/21519.html

相关文章

  • 利用Google云搭建Flarum论坛

    摘要:前言本教程面向新人撰写,无需任何编程语言基础,教你如何搭建一个轻论坛。按照本教程的操作方法,您可以顺利完成搭建并将论坛上线。禁用缓存,存在小的缓存,论坛内的刷新页面并不会刷新内容,而是返回之前的某个时间段,其原因为缓存问题。 前言 本教程面向新人撰写,无需任何编程语言基础,教你如何搭建一个轻论坛。您可以访问 https://flarum.org.cn/ 来了解该更多相关信息。 按照本教...

    MSchumi 评论0 收藏0
  • 利用Google云搭建Flarum论坛

    摘要:前言本教程面向新人撰写,无需任何编程语言基础,教你如何搭建一个轻论坛。按照本教程的操作方法,您可以顺利完成搭建并将论坛上线。禁用缓存,存在小的缓存,论坛内的刷新页面并不会刷新内容,而是返回之前的某个时间段,其原因为缓存问题。 前言 本教程面向新人撰写,无需任何编程语言基础,教你如何搭建一个轻论坛。您可以访问 https://flarum.org.cn/ 来了解该更多相关信息。 按照本教...

    Barrior 评论0 收藏0
  • 强强联合:FluxBB 作者加盟 Flarum

    摘要:原文作者译文强强联合作者加盟译者是一个快速轻量级论坛软件,它的开发者是一名德国的天才。将加入我们,并成为的核心成员,并负责和相关的工作。的加盟将使我们能发挥我们的长处,共同完成一个惊人的论坛软件。 原文:FluxBB Joins Forces With Flarum 作者:Toby Zerner 译文:强强联合:FluxBB 作者加盟 Flarum 译者:justjavac Flu...

    CoyPan 评论0 收藏0
  • Flarum 安装

    摘要:附带了一个的文件,此文件包含了需要用到的规则。然而,在这个阶段还为时过早,我们需要先发布稳定版文章来源中文开发者社区 系统需求 服务器: Apache (需要支持 mod_rewrite) 、Nginx PHP 5.5+ MySQL 5.5+ 在线安装 下载安装包,解压,上传文件到服务器 访问域名根目录 填写网址信息:如网站名称、管理员信息、数据库信息,点击Install Fla...

    Betta 评论0 收藏0
  • 堡塔网站加速插件:为网站加速的插件「wordpress效果测评」

    摘要:堡塔网站加速是宝塔面板为用户开发的一款网站加速插件网站加速插件,基于页面缓存的网站加速插件,支持常见的众多建站程序加速。那么有了堡塔网站加速之后,我们可以使用更多的加速方式,提升网站打开速度。实测加速性能远强于,以下加速效果来自环境。堡塔网站加速是宝塔面板为用户开发的一款网站加速插件,基于页面缓存的网站加速插件,支持常见的众多建站程序加速。其原理是在http协议层缓存动态页面,对实时信息及已...

    番茄西红柿 评论0 收藏2637

发表评论

0条评论

最新活动
阅读需要支付1元查看
<