历史消息
本特性为高级功能,默认不开通,付费应用,可以在我的应用->查看详情,高级功能里自助开通。
获取某个channel上发送的历史消息,您可以根据具体的参数来指定返回符合您期望的历史消息。
范围:可查询每个channel在24小时内最新的1000条消息
channel: 返回此channel上的历史消息
start: 返回某个时间区间的历史消息,时间区间的起始时间,不包含start
end: 返回某个时间区间的历史消息,时间区间的结束时间,包含end
limit: 返回的历史消息条数,默认值是20条,每次最多返回50条
资费:
goEasy.history({
channel: 'my_channel', //必需项
start: 1561347527648, //可选项,开始时间
end: 1561347706447, //可选项,结束时间
limit: 10 //可选项,返回的消息条数,默认为100条,最多1000条
},
function(response){
console.log("收到历史消息: "+ JSON.stringify(response));
/**
response示例:
{
"code":200,
"content":{
"messages":[
{"time":1561347527649,"content":"my 001"}
{"time":1561347596077,"content":"my 002"}
{"time":1561347622613,"content":"my 003"}
{"time":1561347691826,"content":"my 004"}
{"time":1561347706447,"content":"my 005"}
]
}
}
**/
});
Request:
URL: http(s)://<REST HOST>/history?appkey={appkey}&channel={channel}&start={start}&end={end}&limit={limit}
Method: GET
参数:
appkey //必需项,您的rest appkey
channel //必需项
start //可选项,start time millis 如:1561347527648
end //可选项,end time millis 如:1561347706447
limit //可选项,一次获取的消息条数,默认为20条,最多50条
Response JSON:
//response 示例:
{
"code":200,
"content":{
"messages":[
{"time":1561347527649,"content":"my 001"}
{"time":1561347596077,"content":"my 002"}
{"time":1561347622613,"content":"my 003"}
{"time":1561347691826,"content":"my 004"}
{"time":1561347706447,"content":"my 005"}
]
}
}