示例#1
0
        /**
         * 刷新用户信息
         */
        public static RongResult RefreshUser(String appkey, String appSecret, String userId, String name, String portraitUri)
        {
            Dictionary <String, String> dicList = new Dictionary <String, String>();

            dicList.Add("userId", userId);
            if (!string.IsNullOrEmpty(name))
            {
                dicList.Add("name", name);
            }
            if (!string.IsNullOrEmpty(portraitUri))
            {
                dicList.Add("portraitUri", portraitUri);
            }
            String postStr = buildQueryStr(dicList);

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.refreshUserUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="chatroomInfo">chatroom[id10001]=name1001</param>
        /// <returns></returns>
        public static RongResult CreateChatroom(String appkey, String appSecret, String[] chatroomId, String[] chatroomName)
        {
            String postStr = null;

            String id, name;

            for (int i = 0; i < chatroomId.Length; i++)
            {
                id       = HttpUtility.UrlEncode(chatroomId[i], Encoding.UTF8);
                name     = HttpUtility.UrlEncode(chatroomName[i], Encoding.UTF8);
                postStr += "chatroom[" + id + "]=" + name + "&";
            }

            postStr = postStr.Substring(0, postStr.LastIndexOf('&'));

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.createChatroomUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="chatroomId"></param>
        /// <returns></returns>
        public static RongResult joinChatroom(String appkey, String appSecret, string userId, string roomId)
        {
            Dictionary <String, String> dicList = new Dictionary <String, String>();

            dicList.Add("userId", userId);
            dicList.Add("chatroomId", roomId);

            String postStr = buildQueryStr(dicList);

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.joinChatroomUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#4
0
        /// <summary>
        /// 广播消息暂时未开放
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="fromUserId"></param>
        /// <param name="objectName"></param>
        /// <param name="content">RC:TxtMsg消息格式{"content":"hello"}  RC:ImgMsg消息格式{"content":"ergaqreg", "imageKey":"http://www.demo.com/1.jpg"}  RC:VcMsg消息格式{"content":"ergaqreg","duration":3}</param>
        /// <returns></returns>
        public static RongResult BroadcastMessage(String appkey, String appSecret, String fromUserId, String objectName, String content)
        {
            Dictionary <String, String> dicList = new Dictionary <String, String>();

            dicList.Add("content", content);
            dicList.Add("fromUserId", fromUserId);
            dicList.Add("objectName", objectName);
            dicList.Add("pushContent", "");
            dicList.Add("pushData", "");

            String         postStr = buildQueryStr(dicList);
            RongHttpClient client  = new RongHttpClient(appkey, appSecret, InterfaceUrl.broadcastUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#5
0
        /// <summary>
        /// 发送系统消息
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="fromUserId">发送人用户 Id</param>
        /// <param name="toUserId">接收用户Id,提供多个本参数可以实现向多用户发送系统消息,上限为 100 人。</param>
        /// <param name="objectName">消息类型[RC:TxtMsg][RC:ContactNtf]</param>
        /// <param name="objectName">消息类型</param>
        /// <param name="content">发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式</param>
        /// <param name="pushContent">定义显示的 Push 内容,如果 objectName 为融云内置消息类型时,则发送后用户一定会收到 Push 信息。 如果为自定义消息,则 pushContent 为自定义消息显示的 Push 内容,如果不传则用户不会收到 Push 通知</param>
        /// <param name="pushData">针对 iOS 平台为 Push 通知时附加到 payload 中,Android 客户端收到推送消息时对应字段名为 pushData。</param>
        /// <returns></returns>
        public static RongResult PublishSystemMessage(String appkey, String appSecret, String fromUserId, String toUserId, String objectName, String content, String pushContent, String pushData)
        {
            Dictionary <String, String> dicList = new Dictionary <String, String>();

            dicList.Add("fromUserId", fromUserId);
            dicList.Add("toUserId", toUserId);
            dicList.Add("objectName", objectName);
            dicList.Add("content", content);
            if (!string.IsNullOrEmpty(pushData))
            {
                dicList.Add("pushData", pushData);
            }
            if (!string.IsNullOrEmpty(pushContent))
            {
                dicList.Add("pushContent", pushContent);
            }
            String postStr = buildQueryStr(dicList);

            System.Diagnostics.Trace.WriteLine(postStr);
            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.sendSystemMsgUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#6
0
        /**
         * 群组禁言移除
         */
        public static RongResult GagRollbackGroup(String appkey, String appSecret, String[] userId, String groupId)
        {
            List <KeyValuePair <String, String> > dicList = new List <KeyValuePair <String, String> >();

            foreach (var item in userId)
            {
                dicList.Add(new KeyValuePair <string, string>("userId", item));
            }
            dicList.Add(new KeyValuePair <string, string>("groupId", groupId));

            String postStr = buildQueryStr(dicList);

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.gagrollbakGroupUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#7
0
        /**
         * 创建 群组
         */
        public static RongResult RefreshGroup(String appkey, String appSecret, String groupId, String groupName)
        {
            Dictionary <String, String> dicList = new Dictionary <String, String>();

            dicList.Add("groupId", groupId);
            dicList.Add("groupName", groupName);

            String postStr = buildQueryStr(dicList);

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.refreshGroupUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="chatroomIdInfo">chatroomId=id1001</param>
        /// <returns></returns>
        public static RongResult DestroyChatroom(String appkey, String appSecret, String[] chatroomIdInfo)
        {
            String postStr = null;

            postStr = buildParamStr(chatroomIdInfo);

            RongHttpClient client = new RongHttpClient(appkey, appSecret, InterfaceUrl.destroyChatroomUrl, postStr);

            string     retString = client.ExecutePost();
            RongResult result    = new RongResult();

            try
            {
                result = JsonConvert.DeserializeObject <RongResult>(retString);
            }
            catch (Exception)
            {
                result.errorMessage = retString;
                result.code         = "-100";
            }
            return(result);
        }