获取会话消息列表

  • 接口说明: 获取会话消息列表,获取数据后会设置当前会话已读
  • 接口地址: /api/dialog/message
  • 请求方式: GET

请求参数

参数名称类型是否必须描述
includestring关联数据
filter[dialog_id]int会话 ID
page[number]int页码
page[limit]int单页数量
sortstring创建时间正序createdAt,创建时间倒序-createdAt

include 可关联的数据

关联名称模型类型是否默认描述
attachmentattachmentsobject附件(图片)
userusersobject用户
user.groupsgroupsobject用户组

请求示例

  1. /api/dialog/message?filter[dialog_id]=1&include=user

返回说明

  • 成功,http 状态码: 200
  • 失败,http 状态码: 404

返回结果

关联数据模型字段释义参见请参见相应文档

字段名变量名必填类型描述
linksobjectobject接口链接
data.typedata.typestring固定值 dialog_message
data.iddata.idint消息 ID
data.attributesobjectobject数据属性
消息 ididint消息 id
发送人 uidattribute. user_idint发送人 uid
会话 idattribute. dialog_idint会话 id
消息内容attribute. message_textint消息内容
更新时间attributes.updated_atdatetime更新时间
创建时间attributes.created_atdatetime创建时间
data.relationshipsobjectobject关联关系
includedobjectobject关联数据

返回示例

  1. {
  2. "links": {
  3. "first": "DummySiteUrl/api/dialog/message?filter%5Bdialog_id%5D=1&include=user",
  4. "last": "DummySiteUrl/api/dialog/message?filter%5Bdialog_id%5D=1&include=user"
  5. },
  6. "data": [
  7. {
  8. "type": "dialog_message",
  9. "id": "1",
  10. "attributes": {
  11. "user_id": 2,
  12. "dialog_id": 1,
  13. "message_text": "11111",
  14. "updated_at": "2020-02-17T10:14:28+08:00",
  15. "created_at": "2020-02-17T10:14:31+08:00"
  16. },
  17. "relationships": {
  18. "user": {
  19. "data": {
  20. "type": "users",
  21. "id": "2"
  22. }
  23. }
  24. }
  25. },
  26. {
  27. "type": "dialog_message",
  28. "id": "1",
  29. "attributes": {
  30. "user_id": 1,
  31. "dialog_id": 1,
  32. "message_text": "消息内容123",
  33. "updated_at": "2020-02-17T10:14:28+08:00",
  34. "created_at": "2020-02-17T10:14:31+08:00"
  35. },
  36. "relationships": {
  37. "user": {
  38. "data": {
  39. "type": "users",
  40. "id": "1"
  41. }
  42. }
  43. }
  44. },
  45. {
  46. "type": "dialog_message",
  47. "id": "1",
  48. "attributes": {
  49. "user_id": 1,
  50. "dialog_id": 1,
  51. "message_text": "消息内容123",
  52. "updated_at": "2020-02-17T10:14:28+08:00",
  53. "created_at": "2020-02-17T10:14:31+08:00"
  54. },
  55. "relationships": {
  56. "user": {
  57. "data": {
  58. "type": "users",
  59. "id": "1"
  60. }
  61. }
  62. }
  63. },
  64. {
  65. "type": "dialog_message",
  66. "id": "1",
  67. "attributes": {
  68. "user_id": 1,
  69. "dialog_id": 1,
  70. "message_text": "消息内容123",
  71. "updated_at": "2020-02-17T10:14:28+08:00",
  72. "created_at": "2020-02-17T10:14:31+08:00"
  73. },
  74. "relationships": {
  75. "user": {
  76. "data": {
  77. "type": "users",
  78. "id": "1"
  79. }
  80. }
  81. }
  82. }
  83. ],
  84. "included": [
  85. {
  86. "type": "users",
  87. "id": "2",
  88. "attributes": {
  89. "id": 2,
  90. "username": "username",
  91. "mobile": "",
  92. "avatarUrl": "",
  93. "threadCount": 0,
  94. "followCount": 1,
  95. "fansCount": 1,
  96. "follow": null,
  97. "status": 0,
  98. "loginAt": "2020-02-06T19:48:34+08:00",
  99. "joinedAt": "2019-12-20T03:48:09+08:00",
  100. "expiredAt": null,
  101. "createdAt": "2019-12-20T03:48:09+08:00",
  102. "updatedAt": "2020-02-06T19:52:14+08:00",
  103. "canEdit": true,
  104. "canDelete": true,
  105. "registerReason": null,
  106. "originalMobile": "",
  107. "registerIp": "172.16.167.1",
  108. "lastLoginIp": "172.16.167.1",
  109. "identity": null,
  110. "realname": null
  111. }
  112. },
  113. {
  114. "type": "users",
  115. "id": "1",
  116. "attributes": {
  117. "id": 1,
  118. "username": "username",
  119. "mobile": "",
  120. "avatarUrl": "DummySiteUrl/storage/avatars/1.png?1578395431",
  121. "threadCount": 0,
  122. "followCount": 4,
  123. "fansCount": 2,
  124. "follow": null,
  125. "status": 0,
  126. "loginAt": "2020-02-18T15:17:13+08:00",
  127. "joinedAt": "2019-12-19T13:51:19+08:00",
  128. "expiredAt": null,
  129. "createdAt": "2019-12-19T13:51:20+08:00",
  130. "updatedAt": "2020-02-18T15:17:13+08:00",
  131. "canEdit": true,
  132. "canDelete": true,
  133. "registerReason": null,
  134. "originalMobile": "",
  135. "registerIp": "172.16.167.1",
  136. "lastLoginIp": "172.16.167.1",
  137. "identity": null,
  138. "realname": null
  139. }
  140. }
  141. ],
  142. "meta": {
  143. "total": 4,
  144. "size": 20
  145. }
  146. }