注册

根据时间条件下载历史消息文件

{ .... "uri" : "http://a1.easemob.com/easemob-demo/restapp1/chatmessages/2016121214", "data" : [ { "url" : "http://ebs-chatmessage-a1.easemob.com/history/1D/easemob-demo/restapp1/2016121214.gz?Expires=1481532888&OSSAccessKeyId=LTAIlKPZStPokdA8&Signature=Zzt%2ByJ7tj%2Bgq3zxLVK4QrbFutto%3D" //返回的文件下载地址 .... }
参数的意义,怎么使用。最好能够给个例子,谢谢。
已邀请:
首先明确环信的名词:
org_name: appkey中“#”号前的部分
app_name: appkey中“#”号后的部分
这些文档都有,包括管理员token的获取:http://docs.easemob.com/im/100serverintegration/20users

url: http(s)://a1.easemob.com/{org_name}/{app_name}/chatmessages/yyyyMMddhh
最后设置的时间格式为10位,yyyyMMddhh——年月日时
head:“Content-Type”:”application/json”,”Authorization”:”Bearer ${管理员token}
请求方式:POST

返回数据
(2)如需查询2016年12月10号7点到8点的历史记录,则需要输入2016121007,7:00:00的信息也会包含在这个文件里;
(3)因为历史记录文件生成需要一定时间,建议用户在取得历史记录时要间隔一个小时,例如2016/12/10 09:00之后,可以开始下载2016/12/10 07:00 ~ 08:00的消息历史记录;
(4)可能的错误码:400(要取得历史记录已过期、要取得的历史记录文件还没有生成)
404(要获取的这一时间段内没有消息产生)
401(未授权[无token、token错误、token过期])
429  调用达到限流标准,频率是每分钟一次
5xx(详见文档“服务器端REST API常见错误码”:http://docs.easemob.com/start/450errorcode/10restapierrorcode)


 
try
            {
                HttpWebRequest request = WebRequest.Create(reqUrl) as HttpWebRequest;
                request.Method = method.ToUpperInvariant();

                if (!string.IsNullOrEmpty(token) && token.Length > 1) { 
                    request.Headers.Add("Authorization", "Bearer " + token); 
                }
                if (request.Method.ToString() != "GET" && !string.IsNullOrEmpty(paramData) && paramData.Length > 0)
                {
                    request.ContentType = "application/json";
                    byte[] buffer = Encoding.UTF8.GetBytes(paramData);
                    request.ContentLength = buffer.Length;
                    request.GetRequestStream().Write(buffer, 0, buffer.Length);
                    //request.GetRequestStream().Close();
                }

                using (HttpWebResponse resp = request.GetResponse() as HttpWebResponse)
                {
                    using (StreamReader stream = new StreamReader(resp.GetResponseStream(), Encoding.UTF8))
                    {
                        string result = stream.ReadToEnd();
                        return result;
                    }
                }
            }
            catch (Exception ex) { return ex.ToString(); }

我这出来的result一直是空的。没有数据。
 
没有返回下载地址啊。

要回复问题请先登录注册