多米应用API
    多米应用API
    • 说明文档
    • 认证
      • 用户登录
        POST
      • 用户注册
        POST
    • 系统
      • 获取站点信息
        GET
      • 获取系统设置
        GET
    • 版块
      • 获取版块列表
        GET
      • 获取版块详情
        GET
    • 帖子
      • 获取帖子列表
        GET
      • 帖子详情
        GET
      • 回复列表
        GET
    • 发布
      • 发表帖子
        POST
      • 发表回复
        POST
      • 收藏帖子
        POST
      • 推荐帖子
        POST
      • 文件上传
        POST
    • 用户
      • 获取用户信息
        GET
      • 更新用户资料
        POST
      • 获取用户列表
        GET
    • 通知
      • 获取通知消息列表
        POST
      • 获取未读消息统计
        POST
      • 标记消息为已读
        POST
      • 忽略所有消息
        POST
      • 删除消息
        POST
    • 我的
      • 获取用户收藏的帖子
      • 获取用户发布的帖子
      • 获取积分记录
    • 好友
      • 获取好友列表
      • 获取好友分组
      • 添加好友
      • 删除好友
      • 检查好友关系
      • 获取好友请求列表
      • 处理好友请求
      • 修改好友分组
      • 修改好友备注

    说明文档

    多米API插件文档#

    目录#

    1.
    简介
    2.
    认证
    3.
    通用响应格式
    4.
    接口列表
    4.1 论坛相关
    4.2 帖子相关
    4.3 用户相关
    4.4 通知相关
    4.5 好友相关
    4.6 我的内容相关
    4.7 系统相关

    简介#

    多米API插件是为Discuz!X论坛系统开发的RESTful API接口,支持论坛的各种功能,包括论坛浏览、帖子发布与回复、用户注册与登录、通知管理、好友系统等功能。

    API请求url#

    默认:https://dzx35.xcxgy.cn/plugin.php?id=domi_api&mod=threads
    伪静态:https://dzx35.xcxgy.cn/domi_api/threads
    伪静态规则:
    
    # 将 /domi_api/xxx 重写到 plugin.php?id=domi_api&mod=xxx
    location /domi_api/ {
        rewrite ^/domi_api/(\w+)$ /plugin.php?id=domi_api&mod=$1&$args last;
    }

    认证#

    除了登录、注册接口外,所有的POST方式请求的API接口都需要进行用户认证。认证采用JWT (JSON Web Token)方式。

    获取认证令牌#

    通过登录接口获取JWT令牌:
    POST /login

    使用认证令牌#

    在后续请求中,需要在HTTP请求头中加入Authorization头:
    Authorization: Bearer {token}

    通用响应格式#

    所有API响应均采用JSON格式,基本结构如下:
    {
      "code": 200,         // HTTP状态码
      "message": "success", // 状态消息
      "data": {},          // 响应数据
      "timestamp": 1629456789 // 响应时间戳
    }
    状态码说明:
    200: 请求成功
    400: 请求参数错误
    401: 未认证或认证失败
    403: 权限不足
    404: 资源不存在
    405: 请求方法不允许
    500: 服务器内部错误

    接口列表#

    论坛相关#

    获取论坛版块列表#

    GET /forums
    参数:
    参数名类型必填描述
    fidstring否版块ID,可以指定多个,用逗号分隔,如"1,2,3"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "list": [
          {
            "fid": 1,
            "type": "forum",
            "name": "版块名称",
            "status": 1,
            "displayorder": 0,
            "fup": 0,
            "threads": 100,
            "posts": 500,
            "todayposts": 10,
            "description": "版块描述",
            "icon": "图标URL",
            "banner": "横幅URL",
            "lastpost": {
              "tid": 123,
              "subject": "最新帖子标题",
              "dateline": 1629456789,
              "author": "作者"
            },
            "moderators": ["版主1", "版主2"],
            "threadtypes": {
              "1": "类型1", 
              "2": "类型2"
            },
            "perms": {
              "view": [],
              "post": [],
              "reply": [],
              "getattach": [],
              "postattach": []
            }
          }
        ]
      },
      "timestamp": 1629456789
    }

    获取版块详情#

     
    GET /forum_detail
    参数:
    参数名类型必填描述
    fidint/string是版块ID,可以指定多个,用逗号分隔,如"1,2,3"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "fid": 1,
        "type": "forum",
        "name": "版块名称",
        "status": 1,
        "displayorder": 0,
        "fup": 0,
        "threads": 100,
        "posts": 500,
        "todayposts": 10,
        "description": "版块描述",
        "icon": "图标URL",
        "banner": "横幅URL",
        "rules": "版块规则",
        "lastpost": {
          "tid": 123,
          "subject": "最新帖子标题",
          "dateline": 1629456789,
          "author": "作者"
        },
        "moderators": ["版主1", "版主2"],
        "threadtypes": {
          "1": "类型1", 
          "2": "类型2"
        },
        "perms": {
          "view": [],
          "post": [],
          "reply": [],
          "getattach": [],
          "postattach": []
        },
        "extra": {
          "commentitem": [],
          "redirect": "",
          "supe_pushsetting": "",
          "modrecommend": {},
          "picstyle": 0,
          "seotitle": "",
          "keywords": "",
          "seodescription": ""
        }
      },
      "timestamp": 1629456789
    }
    如果请求多个版块ID,则返回格式为:
    {
      "code": 200,
      "message": "success",
      "data": {
        "list": [
          {
            // 版块1信息
          },
          {
            // 版块2信息
          }
        ]
      },
      "timestamp": 1629456789
    }

    帖子相关#

    获取帖子列表#

    GET /threads
    参数:
    参数名类型必填描述
    fidint/string否版块ID,可以指定多个,用逗号分隔,如"1,2,3"
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    orderbystring否排序方式:dateline(默认,发帖时间)、lastpost(最后回复时间)、views(查看次数)、replies(回复数)、heats(热度)
    filterstring否筛选方式:digest(精华)、hot(热门)、recommend(推荐)、attachment(有附件的)、follow(我关注的)
    keywordstring否关键词搜索
    digestint否是否只看精华帖,1为是
    authoridint否作者用户ID
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "threads": [
          {
            "tid": 123,
            "fid": 1,
            "author": "作者",
            "authorid": 456,
            "subject": "帖子标题",
            "dateline": 1629456789,
            "lastpost": 1629457000,
            "lastposter": "最后回复者",
            "views": 100,
            "replies": 10,
            "digest": 0,
            "attachment": 0,
            "recommend": 5,
            "heats": 8,
            "cover": "封面图URL",
            "displayorder": 0,
            "closed": 0,
            "icon": "主题图标",
            "typeid": 0,
            "is_read": false
          }
        ],
        "count": 100,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取帖子详情#

    GET /thread_detail
    参数:
    参数名类型必填描述
    tidint是帖子ID
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "thread": {
          "tid": 123,
          "fid": 1,
          "author": "作者",
          "authorid": 456,
          "subject": "帖子标题",
          "dateline": 1629456789,
          "message": "帖子内容",
          "views": 100,
          "replies": 10,
          "digest": 0,
          "attachment": 1,
          "typeid": 0,
          "closed": 0,
          "highlight": "",
          "displayorder": 0,
          "recommend": 5,
          "heats": 8,
          "status": 0,
          "readperm": 0,
          "price": 0,
          "is_favorite": false,
          "attachments": [
            {
              "aid": 1,
              "tid": 123,
              "uid": 456,
              "filename": "文件名",
              "filesize": 12345,
              "attachment": "a/abc.jpg",
              "remote": 0,
              "isimage": 1,
              "width": 800,
              "thumb": 1,
              "url": "附件URL",
              "dateline": 1629456789,
              "description": "附件描述"
            }
          ]
        },
        "posts": [
          {
            "pid": 789,
            "tid": 123,
            "author": "回复者",
            "authorid": 789,
            "message": "回复内容",
            "dateline": 1629457000,
            "attachment": 0,
            "attachments": [],
            "position": 1,
            "anonymous": 0,
            "status": 0,
            "rate": 0,
            "comment": 0,
            "is_reply": false,
            "is_liked": false,
            "likes": 0
          }
        ],
        "forum": {
          "fid": 1,
          "name": "版块名称",
          "threads": 100,
          "posts": 500
        },
        "count": 10,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取回复列表#

    GET /posts
    参数:
    参数名类型必填描述
    tidint是帖子ID
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    ordertypestring否回帖排序方式:desc(默认,从新到旧)、asc(从旧到新)
    authoridint否只看某个作者的回复
    pidint否特定回复ID
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "posts": [
          {
            "pid": 789,
            "tid": 123,
            "author": "回复者",
            "authorid": 789,
            "message": "回复内容",
            "dateline": 1629457000,
            "attachment": 0,
            "attachments": [],
            "position": 1,
            "anonymous": 0,
            "status": 0,
            "rate": 0,
            "comment": 0,
            "is_reply": false,
            "is_liked": false,
            "likes": 0
          }
        ],
        "count": 10,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    发布帖子#

    POST /threads
    POST /new_thread
    参数:
    参数名类型必填描述
    fidint是版块ID
    subjectstring是帖子标题
    messagestring是帖子内容
    attachmentsarray否附件ID数组
    typeidint否主题分类ID
    readpermint否阅读权限,0为无限制
    priceint否售价,0为免费
    allownoticeauthorint否是否允许回复通知作者,1为允许
    tagsstring否标签,多个标签用逗号分隔
    anonymousint否是否匿名发布,1为匿名
    ishtmlint否是否允许HTML,1为允许
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "tid": 123,
        "pid": 456,
        "subject": "帖子标题",
        "url": "帖子URL"
      },
      "timestamp": 1629456789
    }

    回复帖子#

    POST /posts
    POST /reply
    参数:
    参数名类型必填描述
    tidint是帖子ID
    messagestring是回复内容
    attachmentsarray否附件ID数组
    replysubmitint否确认提交,1为确认
    reppidint否引用回复的ID
    reppostint否是否引用回复,1为引用
    noticetrimstrstring否通知修剪的内容
    noticeauthorint否是否通知作者,1为通知
    usesigint否是否使用签名,1为使用
    htmlonint否是否允许HTML,1为允许
    anonymousint否是否匿名发布,1为匿名
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "pid": 789,
        "tid": 123,
        "position": 12,
        "url": "回复URL"
      },
      "timestamp": 1629456789
    }

    收藏帖子#

    POST /favorite
    参数:
    参数名类型必填描述
    tidint是帖子ID
    actionstring否操作类型:add(添加,默认)、remove(删除)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true
      },
      "timestamp": 1629456789
    }

    推荐帖子#

    POST /recommend
    参数:
    参数名类型必填描述
    tidint是帖子ID
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true
      },
      "timestamp": 1629456789
    }

    上传附件#

    POST /upload
    参数:
    参数名类型必填描述
    fidint是版块ID
    uidint是用户ID
    filefile是上传文件
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "aid": 1,
        "filename": "文件名",
        "filesize": 12345,
        "attachment": "a/abc.jpg",
        "isimage": 1,
        "width": 800,
        "url": "附件URL"
      },
      "timestamp": 1629456789
    }

    用户相关#

    用户登录#

    POST /login
    参数:
    参数名类型必填描述
    usernamestring是用户名
    passwordstring是密码
    questionidint否安全提问ID
    answerstring否安全提问答案
    cookietimeint否Cookie有效期,单位秒,默认2592000(30天)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "token": "JWT令牌",
        "user": {
          "uid": 123,
          "username": "用户名",
          "email": "邮箱",
          "groupid": 10,
          "groupname": "用户组名称",
          "credits": 100,
          "regdate": 1629400000,
          "lastlogin": 1629456789,
          "avatar": "头像URL",
          "status": 1,
          "mobile": "手机号",
          "stats": {
            "posts": 50,
            "threads": 10,
            "digestposts": 5,
            "credits1": 100,
            "credits2": 200,
            "credits3": 0,
            "credits4": 0,
            "credits5": 0,
            "credits6": 0,
            "credits7": 0,
            "credits8": 0,
            "oltime": 100,
            "todayattachs": 0,
            "todayattachsize": 0
          },
          "profile": {
            "realname": "真实姓名",
            "gender": 1,
            "birthyear": 1990,
            "birthmonth": 1,
            "birthday": 1,
            "constellation": "",
            "zodiac": "",
            "telephone": "",
            "mobile": "",
            "idcardtype": "",
            "idcard": "",
            "address": "",
            "zipcode": "",
            "nationality": "",
            "birthprovince": "",
            "birthcity": "",
            "resideprovince": "",
            "residecity": "",
            "residedist": "",
            "residecommunity": "",
            "residesuite": "",
            "graduateschool": "",
            "education": "",
            "company": "",
            "occupation": "",
            "position": "",
            "revenue": "",
            "affectivestatus": "",
            "lookingfor": "",
            "bloodtype": "",
            "height": "",
            "weight": "",
            "alipay": "",
            "icq": "",
            "qq": "",
            "yahoo": "",
            "msn": "",
            "taobao": "",
            "site": "",
            "bio": "个人简介",
            "interest": "兴趣爱好",
            "field1": "",
            "field2": "",
            "field3": "",
            "field4": "",
            "field5": "",
            "field6": "",
            "field7": "",
            "field8": ""
          }
        }
      },
      "timestamp": 1629456789
    }

    用户注册#

    POST /register
    参数:
    参数名类型必填描述
    usernamestring是用户名,3-15个字符
    passwordstring是密码,6-20个字符
    emailstring是邮箱
    mobilestring否手机号
    questionidint否安全提问ID
    answerstring否安全提问答案
    genderint否性别:1(男)、2(女)
    birthyearint否出生年,如1990
    birthmonthint否出生月,1-12
    birthdayint否出生日,1-31
    invitecodestring否邀请码
    regsubmitint否确认提交,1为确认
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "uid": 123,
        "username": "用户名",
        "token": "JWT令牌",
        "groupid": 10,
        "regdate": 1629456789,
        "email": "邮箱",
        "mobile": "手机号"
      },
      "timestamp": 1629456789
    }

    刷新令牌#

    POST /refresh
    参数:
    无需特殊参数,但需要Authorization头部
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "token": "新JWT令牌",
        "uid": 123,
        "username": "用户名",
        "exp": 1632048789 // 过期时间戳
      },
      "timestamp": 1629456789
    }

    获取用户信息#

    GET /users_info
    GET /user_info
    参数:
    参数名类型必填描述
    uidint否用户ID,不填则获取当前登录用户信息
    usernamestring否用户名,与uid二选一
    fieldsstring否要获取的字段,多个字段用逗号分隔,如"profile,stats"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "user": {
          "uid": 123,
          "username": "用户名",
          "email": "邮箱",
          "groupid": 10,
          "groupname": "用户组名称",
          "credits": 100,
          "regdate": 1629400000,
          "lastlogin": 1629456789,
          "avatar": "头像URL",
          "status": 1,
          "mobile": "手机号",
          "stats": {
            "posts": 50,
            "threads": 10,
            "digestposts": 5,
            "credits1": 100,
            "credits2": 200,
            "credits3": 0,
            "credits4": 0,
            "credits5": 0,
            "credits6": 0,
            "credits7": 0,
            "credits8": 0,
            "oltime": 100
          },
          "profile": {
            "realname": "真实姓名",
            "gender": 1,
            "birthyear": 1990,
            "birthmonth": 1,
            "birthday": 1,
            "bio": "个人简介",
            "interest": "兴趣爱好"
          },
          "following": 20, // 关注的人数
          "follower": 50,  // 粉丝数
          "friends": 30    // 好友数
        }
      },
      "timestamp": 1629456789
    }

    获取用户资料详情#

    POST /users_info
    参数:
    参数名类型必填描述
    uidint是用户ID
    fieldsstring否要获取的字段,多个字段用逗号分隔,如"profile,stats"
    响应:
    与GET方法相同

    更新用户信息#

    POST /users_update
    POST /update_user
    参数:
    参数名类型必填描述
    profile[bio]string否个人简介
    profile[realname]string否真实姓名
    profile[gender]int否性别:1(男)、2(女)
    profile[birthyear]int否出生年
    profile[birthmonth]int否出生月
    profile[birthday]int否出生日
    profile[site]string否个人网站
    profile[address]string否地址
    profile[mobile]string否手机号码
    profile[qq]string否QQ号码
    profile[icq]string否ICQ号码
    profile[yahoo]string否Yahoo帐号
    profile[msn]string否MSN帐号
    profile[taobao]string否淘宝帐号
    profile[alipay]string否支付宝帐号
    profile[interest]string否兴趣爱好
    profile[bloodtype]string否血型
    profile[height]string否身高(cm)
    profile[weight]string否体重(kg)
    profile[company]string否公司
    profile[occupation]string否职业
    profile[position]string否职位
    profile[education]string否学历
    profile[graduateschool]string否毕业学校
    avatarfile否头像文件
    emailstring否邮箱
    passwordstring否新密码
    oldpasswordstring否旧密码,更改密码时必填
    questionidint否安全提问ID
    answerstring否安全提问答案
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "updated_fields": ["profile.bio", "profile.mobile", "email"]
      },
      "timestamp": 1629456789
    }

    获取用户列表#

    GET /users
    GET /user_list
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    orderbystring否排序方式:credits(积分)、regdate(注册时间,默认)、posts(发帖数)、lastvisit(最后访问时间)
    groupidint否用户组ID
    keywordstring否搜索关键词,搜索用户名
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "users": [
          {
            "uid": 123,
            "username": "用户名",
            "credits": 100,
            "posts": 50,
            "regdate": 1629400000,
            "lastvisit": 1629456000,
            "avatar": "头像URL",
            "groupid": 10,
            "groupname": "用户组名称",
            "gender": 1,
            "bio": "个人简介"
          }
        ],
        "count": 100,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    通知相关#

    获取通知列表#

    POST /notifications
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    typestring否通知类型:system(系统)、friend(好友)、post(帖子)、follow(关注)、all(所有,默认)
    filterstring否筛选方式:new(未读)、read(已读)、all(全部,默认)
    datelineint否时间戳,获取此时间戳之前的通知
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "notifications": [
          {
            "id": 123,
            "uid": 456,
            "type": "post",
            "new": 1,
            "authorid": 789,
            "author": "通知发送者",
            "note": "通知内容",
            "dateline": 1629456789,
            "from_id": 100,
            "from_idtype": "tid",
            "from_title": "相关帖子标题",
            "from_url": "相关链接",
            "avatar": "发送者头像URL",
            "extra": {
              "fid": 1,
              "subject": "帖子标题",
              "content": "回复内容摘要"
            }
          }
        ],
        "count": {
          "total": 10,
          "new": 5,
          "read": 5
        },
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取通知数量#

    POST /notifications_count
    参数:
    参数名类型必填描述
    filterstring否筛选方式:new(未读)、read(已读)、all(全部,默认)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "count": {
          "total": 10,
          "system": 1,
          "friend": 2,
          "post": 5,
          "follow": 2,
          "new": {
            "total": 5,
            "system": 1,
            "friend": 1,
            "post": 2,
            "follow": 1
          }
        }
      },
      "timestamp": 1629456789
    }

    标记通知为已读#

    POST /notifications_read
    参数:
    参数名类型必填描述
    idint否通知ID,不填则标记所有通知为已读
    typestring否通知类型,标记指定类型的通知为已读:system(系统)、friend(好友)、post(帖子)、follow(关注)
    idsstring否多个通知ID,用逗号分隔,如"1,2,3"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 5  // 受影响的通知数量
      },
      "timestamp": 1629456789
    }

    忽略所有通知#

    POST /notifications_ignore
    参数:
    参数名类型必填描述
    typestring否通知类型,忽略指定类型的所有通知:system(系统)、friend(好友)、post(帖子)、follow(关注)、all(所有,默认)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 10  // 受影响的通知数量
      },
      "timestamp": 1629456789
    }

    删除通知#

    POST /notifications_delete
    参数:
    参数名类型必填描述
    idint否通知ID
    typestring否通知类型,删除指定类型的所有通知
    idsstring否多个通知ID,用逗号分隔,如"1,2,3"
    filterstring否筛选方式:new(删除未读)、read(删除已读)、all(删除全部)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 1  // 受影响的通知数量
      },
      "timestamp": 1629456789
    }

    好友相关#

    获取好友列表#

    POST /friends
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    gidint否好友分组ID,不填则获取所有好友
    keywordstring否搜索关键词,搜索好友用户名
    orderbystring否排序方式:dateline(添加时间,默认)、username(用户名)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "friends": [
          {
            "uid": 123,
            "username": "好友用户名",
            "gid": 1,
            "groupname": "好友分组名称",
            "note": "备注",
            "dateline": 1629456789,
            "avatar": "头像URL",
            "is_online": true,
            "lastactivity": 1629456000,
            "gender": 1,
            "posts": 50,
            "credits": 100,
            "groupid": 10,
            "groupname": "用户组名称",
            "is_mutual": true,
            "follow_mutual": 1
          }
        ],
        "groups": [
          {
            "gid": 1,
            "name": "分组名称",
            "count": 5
          }
        ],
        "count": 10,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取好友分组#

    GET /friend_groups
    参数:
    参数名类型必填描述
    namestring否搜索分组名称
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "groups": [
          {
            "gid": 1,
            "name": "分组名称",
            "count": 5,
            "displayorder": 0
          }
        ],
        "count": 3,
        "default_group": {
          "gid": 0,
          "name": "默认分组",
          "count": 10
        }
      },
      "timestamp": 1629456789
    }

    添加好友#

    POST /friend_add
    参数:
    参数名类型必填描述
    uidint是好友用户ID
    messagestring否验证消息
    gidint否好友分组ID,默认为0(未分组)
    notestring否好友备注
    add_followint否是否同时关注,1为关注
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "status": "pending", // pending(等待验证)、success(添加成功)、exists(已经是好友)
        "message": "请求已发送,等待对方验证"
      },
      "timestamp": 1629456789
    }

    删除好友#

    POST /friend_delete
    参数:
    参数名类型必填描述
    uidint是好友用户ID
    uidsstring否多个好友用户ID,用逗号分隔,如"1,2,3"
    gidint否好友分组ID,删除指定分组的所有好友
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 1, // 受影响的好友数量
        "message": "好友删除成功"
      },
      "timestamp": 1629456789
    }

    检查好友关系#

    POST /friend_check
    参数:
    参数名类型必填描述
    uidint是用户ID
    uidsstring否多个用户ID,用逗号分隔,如"1,2,3"
    响应:
    如果是单个用户ID:
    {
      "code": 200,
      "message": "success",
      "data": {
        "is_friend": true,
        "status": "mutual", // mutual(互为好友)、pending(等待验证)、pendingFrom(对方等待我验证)、none(非好友)
        "gid": 1,
        "groupname": "分组名称",
        "note": "备注",
        "dateline": 1629456789,
        "is_following": true, // 是否关注了该用户
        "is_followed": true   // 是否被该用户关注
      },
      "timestamp": 1629456789
    }
    如果是多个用户ID:
    {
      "code": 200,
      "message": "success",
      "data": {
        "friends": {
          "1": {
            "is_friend": true,
            "status": "mutual",
            "gid": 1
          },
          "2": {
            "is_friend": false,
            "status": "none",
            "gid": 0
          }
        }
      },
      "timestamp": 1629456789
    }

    获取好友请求列表#

    GET /friend_requests
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    directionstring否请求方向:received(收到的请求,默认)、sent(发出的请求)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "requests": [
          {
            "id": 123,
            "uid": 456,
            "username": "请求者用户名",
            "message": "验证消息",
            "dateline": 1629456789,
            "avatar": "头像URL",
            "status": "pending", // pending(待处理)、accepted(已接受)、declined(已拒绝)
            "gender": 1,
            "posts": 50,
            "credits": 100,
            "groupid": 10,
            "groupname": "用户组名称"
          }
        ],
        "count": {
          "total": 3,
          "pending": 2,
          "accepted": 1,
          "declined": 0
        },
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    回应好友请求#

    POST /friend_response
    参数:
    参数名类型必填描述
    idint是请求ID
    actionstring是操作:accept(接受)、decline(拒绝)、ignore(忽略)
    gidint否好友分组ID,默认为0(未分组)
    notestring否好友备注
    add_followint否是否同时关注,1为关注
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "status": "accepted", // accepted(已接受)、declined(已拒绝)、ignored(已忽略)
        "message": "已接受好友请求"
      },
      "timestamp": 1629456789
    }

    更新好友分组#

    POST /friend_group
    参数:
    参数名类型必填描述
    uidint是好友用户ID
    gidint是好友分组ID
    uidsstring否多个好友用户ID,用逗号分隔,如"1,2,3"
    create_groupstring否创建新分组并移动到该分组,提供分组名称
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 1, // 受影响的好友数量
        "new_gid": 0   // 如果创建了新分组,返回新分组ID
      },
      "timestamp": 1629456789
    }

    创建好友分组#

    POST /friend_group_create
    参数:
    参数名类型必填描述
    namestring是分组名称
    displayorderint否显示顺序,默认为0
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "gid": 5,    // 新创建的分组ID
        "name": "分组名称"
      },
      "timestamp": 1629456789
    }

    重命名好友分组#

    POST /friend_group_rename
    参数:
    参数名类型必填描述
    gidint是分组ID
    namestring是新分组名称
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "gid": 5,
        "name": "新分组名称"
      },
      "timestamp": 1629456789
    }

    删除好友分组#

    POST /friend_group_delete
    参数:
    参数名类型必填描述
    gidint是分组ID
    tgidint否目标分组ID,将该分组的好友移动到目标分组,默认为0(未分组)
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "affected": 5  // 受影响的好友数量
      },
      "timestamp": 1629456789
    }

    更新好友备注#

    POST /friend_note
    参数:
    参数名类型必填描述
    uidint是好友用户ID
    notestring是好友备注
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "result": true,
        "uid": 123,
        "note": "新备注"
      },
      "timestamp": 1629456789
    }

    我的内容相关#

    获取我的积分记录#

    POST /points_log
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "logs": [
          {
            "id": 123,
            "uid": 456,
            "operation": "操作类型",
            "relatedid": 0,
            "dateline": 1629456789,
            "extcredits1": 0,
            "extcredits2": 10,
            "extcredits3": 0,
            "extcredits4": 0,
            "extcredits5": 0,
            "extcredits6": 0,
            "extcredits7": 0,
            "extcredits8": 0
          }
        ],
        "count": 10,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取用户发布的帖子#

    GET /user_threads
    POST /user_threads
    参数:
    参数名类型必填描述
    uidint否用户ID,不填则获取当前登录用户的帖子
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "threads": [
          {
            "tid": 123,
            "fid": 1,
            "author": "作者",
            "authorid": 456,
            "subject": "帖子标题",
            "dateline": 1629456789,
            "lastpost": 1629457000,
            "lastposter": "最后回复者",
            "views": 100,
            "replies": 10,
            "digest": 0,
            "attachment": 0
          }
        ],
        "count": 10,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    获取用户收藏的帖子#

    POST /user_favorites
    参数:
    参数名类型必填描述
    pageint否页码,默认为1
    perpageint否每页数量,默认为20,最大100
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "favorites": [
          {
            "tid": 123,
            "fid": 1,
            "author": "作者",
            "authorid": 456,
            "subject": "帖子标题",
            "dateline": 1629456789,
            "lastpost": 1629457000,
            "lastposter": "最后回复者",
            "views": 100,
            "replies": 10,
            "digest": 0,
            "attachment": 0
          }
        ],
        "count": 5,
        "page": 1,
        "perpage": 20
      },
      "timestamp": 1629456789
    }

    系统相关#

    获取站点信息#

    GET /site_info
    参数:
    参数名类型必填描述
    fieldsstring否需要获取的字段,多个字段用逗号分隔,如"bbname,sitename,stats"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "site_name": "站点名称",
        "site_url": "站点URL",
        "version": "Discuz版本",
        "charset": "站点编码",
        "timezone": "站点时区",
        "lang": "站点语言",
        "bbclosed": 0, // 是否关闭站点
        "announcement": "站点公告",
        "stats": {
          "totalmembers": 1000,
          "totalposts": 5000,
          "totalthreads": 1000,
          "activeusers": 100,
          "online": {
            "total": 120,
            "members": 50,
            "guests": 70
          }
        },
        "credits": {
          "extcredits1": {
            "title": "金钱",
            "unit": "元"
          },
          "extcredits2": {
            "title": "积分",
            "unit": "点"
          }
        },
        "plugin_version": "多米API版本号"
      },
      "timestamp": 1629456789
    }

    获取系统设置#

    GET /setting
    参数:
    参数名类型必填描述
    fieldsstring否需要获取的设置,多个设置用逗号分隔,如"register,upload,credits"
    响应:
    {
      "code": 200,
      "message": "success",
      "data": {
        "site_name": "站点名称",
        "site_url": "站点URL",
        "register": {
          "status": 1,
          "allow_register": true,
          "register_validate": 0,
          "register_invite": 0,
          "invite_code": 0,
          "invite_buy": 0,
          "invite_price": 0
        },
        "upload": {
          "allow_upload": true,
          "allow_imgsize": 10000, // 允许的图片最大尺寸(KB)
          "allow_filesize": 5000, // 允许的文件最大尺寸(KB)
          "allow_exts": ["jpg", "jpeg", "gif", "png", "zip", "rar", "pdf"]
        },
        "credit_names": {
          "1": {
            "title": "金钱",
            "unit": "元"
          },
          "2": {
            "title": "积分",
            "unit": "点"
          }
        },
        "app_settings": {
          "allow_anonymous": true,
          "allow_search": true,
          "show_online": true,
          "allow_share": true
        }
      },
      "timestamp": 1629456789
    }
    修改于 2025-05-09 05:59:58
    下一页
    用户登录
    Built with