创建主题接口

  • 接口说明: 创建主题
  • 接口地址: /api/threads
  • 请求方式: POST

请求参数

参数名称类型是否必须描述
titlestring标题(发布帖子时必须)
contentstring内容(发布帖子时支持 Markdown 语法)
pricefloat价格(发布帖子时可设置价格发布付费主题)
attachment_pricefloat附件价格
free_wordsint付费主题可免费阅读字数
typeint文章类型(0:文字 1:帖子 2:视频 3:图片 4:语音 5:问答 6:商品)
longitudefloat经度
latitudefloat纬度
addressstring经纬度坐标对应的地址(如:广东省深圳市深南大道 10000 号)
locationstring经纬度坐标对应的位置(如:腾讯大厦)
file_idstring视频 file_id 视频类型文章必填
file_namestring视频文件名称
cover_urlstring视频封面地址
media_urlstring视频地址
is_anonymousbool是否匿名提问
relationships.categoryobject主题分类关联关系
relationships.attachmentsobject主题图片、附件关联关系
relationships.questionobject问答帖子关联关系
question.be_user_idint回答人的 用户 id
question.order_idstring支付成功后的 订单 id
question.pricefloat问答单价
question.is_onlookerbool是否允许围观 true允许 false不允许

请求示例

  1. {
  2. "data": {
  3. "type": "threads",
  4. "attributes": {
  5. "price": 10,
  6. "attachment_price": 10,
  7. "title": "title",
  8. "type": 5,
  9. "longitude": "116.397469",
  10. "latitude": "39.908821",
  11. "location": "北京市天安门",
  12. "content": "{{$randomWords}} == {{$randomColor}} == {{$randomWords}}",
  13. "is_anonymous": true
  14. },
  15. "relationships": {
  16. "category": {
  17. "data": {
  18. "type": "categories",
  19. "id": 6
  20. }
  21. },
  22. "attachments": {
  23. "data": [
  24. {
  25. "type": "attachments",
  26. "id": 1
  27. },
  28. {
  29. "type": "attachments",
  30. "id": 2
  31. }
  32. ]
  33. },
  34. "question": {
  35. "data": {
  36. "be_user_id": 1,
  37. "order_id": "20200918*****1554956",
  38. "price": 100,
  39. "is_onlooker": true
  40. }
  41. }
  42. }
  43. }
  44. }

返回说明

  • 成功,http 状态码 201
  • 失败,http 状态码 500

返回结果

参数名称类型出现要求描述
linksobject接口链接
dataobject基础数据
typestring数据类型
idint数据 id
attributesobject数据属性
typeint文章类型(0 普通 1 长文 2 视频)
titlestring长文主题标题
pricefloat长文主题主题价格
attachment_pricefloat附件价格
viewCountint查看数
postCountint帖子数
paidCountnt付费数
rewardedCountnt打赏数
longitudefloat经度
latitudefloat纬度
addressstring经纬度坐标对应的地址(如:广东省深圳市深南大道 10000 号)
locationstring经纬度坐标对应的位置(如:腾讯大厦)
createdAtdatetime创建时间
updatedAtdatetime修改时间
deletedAtdatetime在回收站时删除时间
isApprovedbool是否合法(0/1/2)
0 不合法
1 正常
2 忽略
isStickybool是否置顶
isEssencebool是否加精
isFavoritebool已收藏时是否收藏
paidbool付费主题是否付费
canViewPostsbool是否有权查看详情
canReplybool是否有权回复
canApprovebool是否有权审核
canStickybool是否有权置顶
canEssencebool是否有权加精
canDeletebool是否有权永久删除
canHidebool是否有权放入回收站
canFavoritebool是否有权收藏
relationshipsobject关联关系
thread-video. statusint视频状态 0:转码中 1 转码完成 2 转码失败
thread-video. reasonstring转码失败原因
thread-video. file_namestring视频文件名称
thread-video. file_idstring媒体文件唯一标识
thread-video. media_urlstring媒体播放地址
thread-video. cover_urlstring媒体封面地址
includedobject关联数据

返回示例

  1. {
  2. "data": {
  3. "type": "threads",
  4. "id": "25",
  5. "attributes": {
  6. "type": 2,
  7. "title": "",
  8. "price": "0.00",
  9. "attachment_price": "0.00",
  10. "viewCount": 1,
  11. "postCount": 1,
  12. "paidCount": 0,
  13. "rewardedCount": 0,
  14. "longitude": "116.397469",
  15. "latitude": "39.908821",
  16. "location": "北京市天安门",
  17. "createdAt": "2020-03-10T16:31:54+08:00",
  18. "updatedAt": "2020-03-10T16:31:54+08:00",
  19. "isApproved": 1,
  20. "isSticky": false,
  21. "isEssence": false,
  22. "canViewPosts": true,
  23. "canReply": false,
  24. "canApprove": false,
  25. "canSticky": false,
  26. "canEssence": false,
  27. "canDelete": false,
  28. "canHide": false,
  29. "canFavorite": false
  30. },
  31. "relationships": {
  32. "user": {
  33. "data": {
  34. "type": "users",
  35. "id": "3"
  36. }
  37. },
  38. "firstPost": {
  39. "data": {
  40. "type": "posts",
  41. "id": "23"
  42. }
  43. },
  44. "threadVideo": {
  45. "data": {
  46. "type": "thread-video",
  47. "id": "18"
  48. }
  49. },
  50. "posts": {
  51. "data": []
  52. }
  53. }
  54. },
  55. "included": [
  56. {
  57. "type": "users",
  58. "id": "3",
  59. "attributes": {
  60. "id": 3,
  61. "username": "username",
  62. "avatarUrl": "",
  63. "threadCount": 19,
  64. "followCount": 0,
  65. "fansCount": 0,
  66. "follow": null,
  67. "status": 0,
  68. "loginAt": "2020-03-10T11:20:42+08:00",
  69. "joinedAt": "2020-03-09T16:39:28+08:00",
  70. "expiredAt": null,
  71. "createdAt": "2020-03-09T16:39:28+08:00",
  72. "updatedAt": "2020-03-10T17:03:44+08:00",
  73. "canEdit": false,
  74. "canDelete": false,
  75. "registerReason": "",
  76. "banReason": ""
  77. }
  78. },
  79. {
  80. "type": "posts",
  81. "id": "23",
  82. "attributes": {
  83. "replyUserId": null,
  84. "content": "abc",
  85. "contentHtml": "abc",
  86. "replyCount": 0,
  87. "likeCount": 0,
  88. "createdAt": "2020-03-10T16:31:54+08:00",
  89. "updatedAt": "2020-03-10T16:31:54+08:00",
  90. "isFirst": true,
  91. "isApproved": 1,
  92. "canEdit": false,
  93. "canApprove": false,
  94. "canDelete": false,
  95. "canHide": false,
  96. "canLike": false
  97. },
  98. "relationships": {
  99. "images": {
  100. "data": []
  101. },
  102. "attachments": {
  103. "data": []
  104. }
  105. }
  106. },
  107. {
  108. "type": "thread-video",
  109. "id": "18",
  110. "attributes": {
  111. "id": 18,
  112. "user_id": 3,
  113. "thread_id": 25,
  114. "status": 1,
  115. "reason": "source file err: file info lack width, height or color space",
  116. "file_name": "66",
  117. "file_id": "66",
  118. "media_url": "url",
  119. "cover_url": "url",
  120. "updated_at": "2020-03-10T18:26:31+08:00",
  121. "created_at": "2020-03-10T16:31:54+08:00"
  122. }
  123. }
  124. ]
  125. }