帖子

优质
小牛编辑
123浏览
2023-12-01

圈子帖子列表

GET /groups/:group/posts

响应

status 200

参数说明

名称类型说明
typestring默认:latest_post, latest_post 最新帖子,latest_reply最新回复
limitinteger默认 15 ,数据返回条数 默认为15
offsetinteger默认 0 ,数据偏移量,传递之前通过接口获取的总数。
excellentany可选,不传递,表示获取全部帖子,传递 1 表示获取精华帖子。
[
  {
    "id": 88,
    "group_id": 1,
    "user_id": 1,
    "title": "内容标题",
    "summary": "帖子介绍",
    "likes_count": 0,
    "comments_count": 0,
    "views_count": 0,
    "liked":true,
    "collected":true,
    "created_at": "2017-11-28 07:12:20",
    "updated_at": "2017-11-28 07:12:20",
    "excellent_at": "2018-08-22T06:27:15Z", // 如果存在,则表示精华
    "images": [
      {
        "id": 113,
        "size": "397x246"
      },
      {
        "id": 115,
        "size": "397x246"
      }
    ],
    "user": {
      "id": 1,
      "name": "admin",
      "bio": null,
      "sex": 2,
      "location": "四川省 巴中市 南江县",
      "created_at": "2017-10-23 01:17:34",
      "updated_at": "2017-11-15 07:36:17",
      "avatar": "http://thinksns-plus.dev/api/v2/users/1/avatar",
      "bg": null,
      "verified": {
        "type": "user",
        "icon": "https://www.xnip.cn/wp-content/uploads/2021/docimg15/40-5g2grumben0.png",
        "description": "1111"
      },
      "extra": {
        "user_id": 1,
        "likes_count": 5,
        "comments_count": 3,
        "followers_count": 0,
        "followings_count": 6,
        "updated_at": "2017-11-27 07:25:04",
        "feeds_count": 8,
        "questions_count": 2,
        "answers_count": 0,
        "checkin_count": 7,
        "last_checkin_count": 1
      }
    }
  }
]

返回参数说明

名称类型说明
gourp_idint所属圈子
user_idint发布者
titlestring标题
summarystring列表专用字段,概述,简短内容
likes_countint喜欢数量统计
comments_countint评论数量统计
views_countint查看数量统计
collectedbool是否收藏true or false
likedbool是否点赞true or false
imagesarray附件

圈子帖子详情

GET /groups/:group/posts/:post

响应

status 200
{
  "id": 81,
  "group_id": 1,
  "user_id": 1,
  "title": "这是帖11",
  "body": "这是帖子",
  "summary": "",
  "likes_count": 0,
  "comments_count": 0,
  "views_count": 0,
  "created_at": "2017-11-28 06:46:02",
  "updated_at": "2017-11-28 07:16:46",
  "excellent_at": "2018-08-22T06:27:15Z", // 如果存在,则表示精华
  "liked": false,
  "collected": false,
  "reward_amount": 0,
  "reward_number": 0,
  "group": {
    "id": 1,
    "name": "哈哈哈",
    "user_id": 1,
    "category_id": 1,
    "location": null,
    "longitude": null,
    "latitude": null,
    "geo_hash": null,
    "allow_feed": 0,
    "mode": "public",
    "money": 0,
    "summary": "简介\n",
    "notice": "这是公告",
    "users_count": 1,
    "posts_count": 47,
    "audit": 1,
    "created_at": null,
    "updated_at": "2017-11-28 07:12:20"
  },
  "user": {
    "id": 1,
    "name": "admin",
    "bio": null,
    "sex": 2,
    "location": "四川省 巴中市 南江县",
    "created_at": "2017-10-23 01:17:34",
    "updated_at": "2017-11-15 07:36:17",
    "avatar": "http://thinksns-plus.dev/api/v2/users/1/avatar",
    "bg": null,
    "verified": {
      "type": "user",
      "icon": "https://www.xnip.cn/wp-content/uploads/2021/docimg15/40-5g2grumben0.png",
      "description": "1111"
    },
    "extra": {
      "user_id": 1,
      "likes_count": 5,
      "comments_count": 3,
      "followers_count": 0,
      "followings_count": 6,
      "updated_at": "2017-11-27 07:25:04",
      "feeds_count": 8,
      "questions_count": 2,
      "answers_count": 0,
      "checkin_count": 7,
      "last_checkin_count": 1
    }
  }
}

返回参数说明

名称类型说明
gourp_idint所属圈子
user_idint发布者
titlestring标题
bodystringmarkdown 内容
summarystring列表专用字段,概述,简短内容
likes_countint喜欢数量统计
comments_countint评论数量统计
views_countint查看数量统计
reward_amountint打赏金额统计
reward_numberint打赏人数统计
collectedbool是否收藏true or false
likedbool是否点赞true or false

圈子帖子创建

参数说明

POST /groups/:group/posts
名称类型说明
titleint必须 帖子标题
bodyint必须 帖子内容
summarystring必须 允许为空 列表专用字段,概述,简短内容
imagesarray文件id,例如[1,2,3],当summay为空时必须传
sync_feedint同步至动态,同步需要传sync_feed = 1
feed_fromint设备标示 同步动态需要传 1:pc 2:h5 3:ios 4:android 5:其他

响应

status 201
{
  "message": "操作成功",
  "post": {
    "title": "这是帖11",
    "body": "这是帖子",
    "summary": "12321321",
    "user_id": 1,
    "group_id": 1,
    "updated_at": "2017-11-28 09:45:17",
    "created_at": "2017-11-28 09:45:17",
    "id": 121
  }
}

圈子帖子更新

参数说明

PUT /groups/:group/posts/:post
名称类型说明
titleint必须 帖子标题
bodyint必须 帖子内容
summarystring必须 允许为空 列表专用字段,概述,简短内容
imagesarray文件id,例如[1,2,3],当summay为空时必须传
sync_feedint同步至动态,同步需要传sync_feed = 1
feed_fromint设备标示 同步动态需要传 1:pc 2:h5 3:ios 4:android 5:其他

响应

status 201
{
  "message": "操作成功",
  "post": {
    "title": "这是帖11",
    "body": "这是帖子",
    "summary": "12321321",
    "user_id": 1,
    "group_id": 1,
    "updated_at": "2017-11-28 09:45:17",
    "created_at": "2017-11-28 09:45:17",
    "id": 121
  }
}

圈子帖子删除

DELETE /groups/:group/posts/:post

响应

status 204 No Content

我的帖子列表

GET /user-group-posts

参数说明

名称类型说明
typestring默认:1 , 1-发布的 2- 已置顶 3-置顶待审
limitinteger默认 15 ,数据返回条数 默认为15
offsetinteger默认 0 ,数据偏移量,传递之前通过接口获取的总数。

响应

status 200

全部帖子列表包含搜索

GET /group-posts

参数说明

名称类型说明
keywordstring搜索关键词,模糊匹配圈子名称
group_idinteger获取某个圈子下面的全部帖子
limitinteger默认 15 ,数据返回条数 默认为15
offsetinteger默认 0 ,数据偏移量,传递之前通过接口获取的总数。

响应

status 200

批量获取帖子简单数据

GET /group/simple-posts

请求查询参数:

名称类型描述
idstring需要获取的帖子 ID, 多个使用半角 , 进行分割

响应:

Status: 200 OK
[
  {
    "id": 1,        // 帖子 ID
    "group_id": 1,    // 所属圈子 ID
    "title": "帖子标题",   // 帖子标题
    "summary": "帖子内容", // 帖子列表语言内容数据
    "image": 1,       // 图片 ID
  }
]

设置帖子精华

帖子取消精华

PUT /api/v2/group/posts/:postId/toggle-excellent

变量:

| 变量 | 描述 | | postId | 帖子 ID。|

响应:

Status: 204 No Content

预览帖子列表接口

这个接口用于用户未加入圈子时展示

GET group/groups/:groupId/preview-posts

变量:

变量描述
groupId圈子 ID

响应:

Status: 200 OK
[
  {
    "id": 1,                // 帖子 ID
    "group_id": 1,              // 所属圈子 ID
    "user_id": 1,               // 帖子发布者
    "title": "haha",            // 帖子标题
    "summary": "1",             // 列表描述内容
    "likes_count": 0,             // 点赞量
    "comments_count": 0,          // 帖子评论量
    "views_count": 0,             // 帖子阅读量
    "created_at": "2018-08-22T06:27:15Z",   // 帖子发布时间
    "excellent_at": "2018-08-22T06:27:15Z", // 如果存在,则表示精华
    "images": [
      {
        "id": 1,
        "size": "160x160"
      }
    ],
    "comments": []               // 参考评论资源返回(服用的代码,批量获取评论接口返回结构)
  }
]