差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版 两侧同时换到之后的修订记录
im:server:basics:chatrecord [2019/09/26 08:37]
huanxinfudh [聊天记录]
im:server:basics:chatrecord [2019/11/01 06:39]
huanxinfudh
行 294: 行 294:
 ---- ----
  
-===== 拉取历史消息 ===== 
  
-根据请求的时间范围一次性获取聊天记录,每次最多返回1000条记录。''​该接口已停用''​ 
-^名称^请求^描述^ 
-|根据 timestamp 查询聊天记录|/​{org_name}/​{app_name}/​chatmessages?​ql=select+*+where+{timestamp}|根据指定的时间范围获取历史消息| 
-|分页获取数据|/​{org_name}/​{app_name}/​chatmessages?​ql=select+*+where+{timestamp}|分页获取根据指定的时间范围获取历史消息| 
-==== 根据 timestamp 查询聊天记录 ==== 
- 
-在 URL 后面加上参数''​ql=select * where timestamp>​1403164734226''​或者''​ql=select * where timestamp<​1403164734226''​。“=”后的参数需要转义。 
-如只取最近的消息可以只用''​timestamp>​1403166586000''​,然后记录获取到的最后一条消息的 timestamp,作为下次获取时使用的 timestamp,按此方法往下查询。 
-需要导出聊天记录的,可以结合 cursor 分页来查询出所需要的聊天记录。聊天记录查询接口返回数据已经按照 timestamp 字段做了升序排序。 
-不能使用 and、or 等操作符来组成这种查询''​ql=select * where timestamp<​1403164734226 and timestamp>​1403166586000''​。 
- 
- 
-=== HTTP Request === 
- 
-^{{:​im:​server:​ready:​get.png?​nolink&​90 |}}^**/​{org_name}/​{app_name}/​chatmessages?​ql=select+*+where+{timestamp}**^ 
-请求参数中{timestamp}代表的是时间范围,详情见描述 
- 
-=== Request Headers === 
- 
-^参数^说明^ 
-|Content-Type|application/​json| 
-|Authorization|Bearer ${token}| 
- 
-=== Response Body === 
- 
-^参数^说明^ 
-|msg_id|消息ID| 
-|timestamp|消息发送时间| 
-|from|发送人username| 
-|to|接收人的username或者接收group的ID| 
-|chat_type|用来判断单聊还是群聊。chat:​ 单聊;groupchat:​ 群聊| 
-|payload|消息bodies,不同的消息类型;消息ext,自定义扩展属性等| 
- 
- 
-=== 请求示例 === 
- 
-<code php> 
-curl -X GET -i -H "​Authorization:​ Bearer YWMtxc6K0L1aEeKf9LWFzT9xEAAAAT7MNR_9OcNq-GwPsKwj_TruuxZfFSC2eIQ"​ "​https://​a1.easemob.com/​easemob-demo/​chatdemoui/​chatmessages?​ql=select+*+where+timestamp>​1403164734226"​ 
-</​code>​ 
- 
-=== 可能返回的结果示例 === 
- 
-**返回值200,表示成功返回了聊天记录文件下载地址** 
- 
-<code json> 
-{ 
- "​count"​ : 10, 
- "​cursor"​ : "​asdsdfaee", ​ 
- "​entities"​ : [ 
- { 
- } 
- ] 
-} 
-</​code>​ 
- 
-**返回值400,表示参数 ql 结构错误** 
- 
-**返回值401,表示未授权[无token、token错误、token过期]** 
- 
-如果返回结果是<​wrap em>​5xx</​wrap>​,有可能代表该接口被限流了,请稍微暂停一下并重试。详见[[im:​450errorcode:​45restastrict|接口限流说明]] 
- 
-[[http://​api-docs.easemob.com/​|使用 Easemob REST API 在线测试]] 
- 
----- 
- 
-==== 分页获取数据 ==== 
-使用 limit 参数获取数据完毕后,如果后边还有数据,会返回一个不为空的 cursor 回来,使用这个 cursor 就能进行分页获取了。 
-分页示例:根据之前获取数据返回的 cursor 继续获取后面的20条数据。在 URL 后面加上参数 cursor,ql 语句保持不变。 
-**(一分钟最多调用10次,每次 limit 最大值为1000。)** 
- 
-=== HTTP Request === 
- 
-^{{:​im:​server:​ready:​get.png?​nolink&​90 |}}^**/​{org_name}/​{app_name}/​chatmessages?​ql=select+*+where+{timestamp}**^ 
-请求参数中{timestamp}代表的是时间范围,详情见描述 
- 
-=== Request Headers === 
- 
-^参数^说明^ 
-|Content-Type|application/​json| 
-|Authorization|Bearer ${token}| 
- 
-=== Response Body === 
-在返回值中查看entities字段包含的信息 
-^参数^说明^ 
-|msg_id|消息ID| 
-|timestamp|消息发送时间| 
-|from|发送人username| 
-|to|接收人的username或者接收group的ID| 
-|chat_type|用来判断单聊还是群聊。chat:​ 单聊;groupchat:​ 群聊| 
-|payload|消息bodies,不同的消息类型;消息ext,自定义扩展属性等| 
- 
- 
-=== 请求示例 === 
- 
-<code php> 
-curl -X GET -i -H "​Authorization:​ Bearer YWMtxc6K0L1aEeKf9LWFzT9xEAAAAT7MNR_9OcNq-GwPsKwj_TruuxZfFSC2eIQ"​ "​https://​a1.easemob.com/​easemob-demo/​testapp/​chatmessages?​ql=select+*+where+timestamp>​1403164734226&​limit=20&​cursor=MTYxOTcyOTYyNDpnR2tBQVFNQWdHa0FCZ0ZHczBKN0F3Q0FkUUFRYUdpdkt2ZU1FZU9vNU4zVllyT2pqUUNBZFFBUWFHaXZJUGVNRWVPMjdMRWo5b0w4dEFB"​ 
-</​code>​ 
- 
-=== 可能返回的结果示例 === 
- 
-**返回值200,表示成功返回了聊天记录文件下载地址** 
- 
-<code json> 
-{ 
- "​count"​ : 10, 
- "​cursor"​ : "​asdsdfaee", ​ 
- "​entities"​ : [ 
- { 
- } 
- ] 
-} 
-</​code>​ 
- 
-**返回值400,表示参数 ql 结构错误** 
- 
- 
-**返回值401,表示未授权[无token、token错误、token过期]** 
- 
- 
-如果返回结果是<​wrap em>​5xx</​wrap>​,有可能代表该接口被限流了,请稍微暂停一下并重试。详见[[im:​450errorcode:​45restastrict|接口限流说明]] 
- 
-[[http://​api-docs.easemob.com/​|使用 Easemob REST API 在线测试]] 
- 
- 
----- 
-<WRAP group> 
-<WRAP half column> 
-上一页:[[im:​server:​basics:​chatroom|聊天室管理]] 
-</​WRAP>​ 
- 
-<WRAP half column> 
-下一页:[[im:​server:​basics:​fileoperation|文件上传下载]] 
-</​WRAP>​ 
-</​WRAP>​