Example #1
0
        /**
         * 发送广播消息方法(发送消息给一个应用下的所有注册用户,如用户未在线会对满足条件(绑定手机终端)的用户发送 Push 信息,单条消息最大 128k,会话类型为 SYSTEM。每小时只能发送 1 次,每天最多发送 3 次。)
         *
         * @param  fromUserId:发送人用户 Id。(必传)
         * @param  txtMessage:文本消息。
         * @param  pushContent:定义显示的 Push 内容,如果 objectName 为融云内置消息类型时,则发送后用户一定会收到 Push 信息. 如果为自定义消息,则 pushContent 为自定义消息显示的 Push 内容,如果不传则用户不会收到 Push 通知.(可选)
         * @param  pushData:针对 iOS 平台为 Push 通知时附加到 payload 中,Android 客户端收到推送消息时对应字段名为 pushData。(可选)
         * @param  os:针对操作系统发送 Push,值为 iOS 表示对 iOS 手机用户发送 Push ,为 Android 时表示对 Android 手机用户发送 Push ,如对所有用户发送 Push 信息,则不需要传 os 参数。(可选)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut broadcast(String fromUserId, messages.Message message, String pushContent, String pushData, String os)
        {
            if (fromUserId == null)
            {
                throw new ArgumentNullException("Paramer 'fromUserId' is required");
            }

            if (message.getType() == null)
            {
                throw new ArgumentNullException("Paramer 'ObjectName' is required");
            }

            if (message.ToString() == null)
            {
                throw new ArgumentNullException("Paramer 'Content' is required");
            }

            String postStr = "";

            postStr += "fromUserId=" + HttpUtility.UrlEncode(fromUserId == null ? "" : fromUserId, Encoding.UTF8) + "&";
            postStr += "objectName=" + HttpUtility.UrlEncode(message.getType(), Encoding.UTF8) + "&";
            postStr += "content=" + HttpUtility.UrlEncode(message.ToString(), Encoding.UTF8) + "&";
            postStr += "pushContent=" + HttpUtility.UrlEncode(pushContent == null ? "" : pushContent, Encoding.UTF8) + "&";
            postStr += "pushData=" + HttpUtility.UrlEncode(pushData == null ? "" : pushData, Encoding.UTF8) + "&";
            postStr += "os=" + HttpUtility.UrlEncode(os == null ? "" : os, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/broadcast.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #2
0
        /// <summary>
        /// 查询敏感词列表方法
        /// </summary>
        public async Task <ListWordfilterReslut> GetList()
        {
            string postStr = "";

            return(JsonConvert.DeserializeObject <ListWordfilterReslut>(await RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/wordfilter/list.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #3
0
        /// <summary>
        /// 融云-获取Token
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        public ReturnValueModel GetToken(WorkUser workUser)
        {
            ReturnValueModel rvm = new ReturnValueModel();
            StringBuilder    sb  = new StringBuilder();

            string tourist = $"{ConfigurationManager.AppSettings["HostUrl"]}/Content/images/Tourist.jpg";//游客头像

            if (!string.IsNullOrEmpty(workUser?.WxUser?.Id))
            {
                var doctor = _rep.FirstOrDefault <WxUserModel>(s => s != null && s.IsDeleted != 1 && s.Id == workUser.WxUser.Id);
                if (doctor == null)
                {
                    rvm.Msg     = "获取用户失败";
                    rvm.Success = false;
                    rvm.Result  = workUser.WxUser.Id;
                    return(rvm);
                }
                var name        = string.IsNullOrEmpty(doctor.WxName) ? "游客" : doctor.WxName;
                var portraitUri = string.IsNullOrEmpty(doctor.WxPicture) ? tourist : doctor.WxPicture;
                sb.Append("&userId=").Append(HttpUtility.UrlEncode(doctor.Id.ToString(), Encoding.UTF8));
                sb.Append("&name=").Append(HttpUtility.UrlEncode(name, Encoding.UTF8));
                sb.Append("&portraitUri=").Append(HttpUtility.UrlEncode(portraitUri, Encoding.UTF8));
            }
            else
            {
                sb.Append("&userId=").Append(HttpUtility.UrlEncode(Guid.NewGuid().ToString(), Encoding.UTF8));
                sb.Append("&name=").Append(HttpUtility.UrlEncode("游客", Encoding.UTF8));
                sb.Append("&portraitUri=").Append(HttpUtility.UrlEncode(tourist, Encoding.UTF8));
            }

            String body = sb.ToString();

            if (body.IndexOf("&") == 0)
            {
                body = body.Substring(1, body.Length - 1);
            }

            string appKey    = ConfigurationManager.AppSettings["RongCloudAppKey"];
            string appSecret = ConfigurationManager.AppSettings["RongCloudAppSecret"];
            string _host     = ConfigurationManager.AppSettings["RongCloudUrl"];
            string url       = $"{_host}/user/getToken.json";

            string result = RongHttpClient.ExecutePost(appKey, appSecret, body, url, "application/x-www-form-urlencoded");

            var res = (TokenResult)RongJsonUtil.JsonStringToObj <TokenResult>(result);

            if (res.Code == 200)
            {
                rvm.Msg     = "success";
                rvm.Success = true;
                rvm.Result  = res;
                return(rvm);
            }
            else
            {
                rvm.Msg     = "获取Token失败";
                rvm.Success = false;
                rvm.Result  = result;
                return(rvm);
            }
        }
Example #4
0
        /**
         * 获取被封禁用户方法(每秒钟限 100 次)
         *
         *
         * @return QueryBlockUserReslut
         **/
        public QueryBlockUserReslut queryBlock()
        {
            String postStr = "";

            return((QueryBlockUserReslut)RongJsonUtil.JsonStringToObj <QueryBlockUserReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/block/query.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #5
0
        /**
         * 查询被封禁聊天室成员方法
         *
         * @param  chatroomId:聊天室 Id。(必传)
         *
         * @return ListBlockChatroomUserReslut
         **/
        public ListBlockChatroomUserReslut getListBlockUser(String chatroomId)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            String postStr = "";

            postStr += "chatroomId=" + HttpUtility.UrlEncode(chatroomId == null ? "" : chatroomId, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((ListBlockChatroomUserReslut)RongJsonUtil.JsonStringToObj <ListBlockChatroomUserReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/user/block/list.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #6
0
        /**
         * 添加聊天室白名单成员方法
         *
         * @param  chatroomId:聊天室中用户 Id,可提交多个,聊天室中白名单用户最多不超过 5 个。(必传)
         * @param  userId:聊天室 Id。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut addWhiteListUser(String chatroomId, String[] userId)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            String postStr = "";

            postStr += "chatroomId=" + HttpUtility.UrlEncode(chatroomId == null ? "" : chatroomId, Encoding.UTF8) + "&";
            for (int i = 0; i < userId.Length; i++)
            {
                String child = userId[i];
                postStr += "userId=" + HttpUtility.UrlEncode(child, Encoding.UTF8) + "&";
            }

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/user/whitelist/add.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #7
0
        /**
         * 刷新群组信息方法
         *
         * @param  groupId:群组 Id。(必传)
         * @param  groupName:群名称。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut refresh(String groupId, String groupName)
        {
            if (groupId == null)
            {
                throw new ArgumentNullException("Paramer 'groupId' is required");
            }

            if (groupName == null)
            {
                throw new ArgumentNullException("Paramer 'groupName' is required");
            }

            String postStr = "";

            postStr += "groupId=" + HttpUtility.UrlEncode(groupId == null ? "" : groupId, Encoding.UTF8) + "&";
            postStr += "groupName=" + HttpUtility.UrlEncode(groupName == null ? "" : groupName, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/group/refresh.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #8
0
        /**
         * 聊天室消息恢复分发方法
         *
         * @param  chatroomId:聊天室 Id。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut resumeDistributionMessage(String chatroomId)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            String postStr = "";

            postStr += "chatroomId=" + HttpUtility.UrlEncode(chatroomId == null ? "" : chatroomId, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/message/resumeDistribution.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #9
0
        /**
         * 查询敏感词列表方法
         *
         *
         * @return ListWordfilterReslut
         **/
        public ListWordfilterReslut getList()
        {
            String postStr = "";

            return((ListWordfilterReslut)RongJsonUtil.JsonStringToObj <ListWordfilterReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/wordfilter/list.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #10
0
        /**
         * 移除敏感词方法(从敏感词列表中,移除某一敏感词。)
         *
         * @param  word:敏感词,最长不超过 32 个字符。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut delete(String word)
        {
            if (word == null)
            {
                throw new ArgumentNullException("Paramer 'word' is required");
            }

            String postStr = "";

            postStr += "word=" + HttpUtility.UrlEncode(word == null ? "" : word, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/wordfilter/delete.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #11
0
        /**
         * 发送单聊模板消息方法(一个用户向多个用户发送不同消息内容,单条消息最大 128k。每分钟最多发送 6000 条信息,每次发送用户上限为 1000 人。)
         *
         * @param  templateMessage:单聊模版消息。
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut publishTemplate(TemplateMessage templateMessage)
        {
            if (templateMessage == null)
            {
                throw new ArgumentNullException("Paramer 'templateMessage' is required");
            }

            String postStr = "";

            postStr = JsonConvert.SerializeObject(templateMessage);
            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/private/publish_template.json", postStr, "application/json")));
        }
Example #12
0
        /**
         * 发送单聊消息方法(一个用户向另外一个用户发送消息,单条消息最大 128k。每分钟最多发送 6000 条信息,每次发送用户上限为 1000 人,如:一次发送 1000 人时,示为 1000 条消息。)
         *
         * @param  fromUserId:发送人用户 Id。(必传)
         * @param  toUserId:接收用户 Id,可以实现向多人发送消息,每次上限为 1000 人。(必传)
         * @param  voiceMessage:消息。
         * @param  pushContent:定义显示的 Push 内容,如果 objectName 为融云内置消息类型时,则发送后用户一定会收到 Push 信息。如果为自定义消息,则 pushContent 为自定义消息显示的 Push 内容,如果不传则用户不会收到 Push 通知。(可选)
         * @param  pushData:针对 iOS 平台为 Push 通知时附加到 payload 中,Android 客户端收到推送消息时对应字段名为 pushData。(可选)
         * @param  count:针对 iOS 平台,Push 时用来控制未读消息显示数,只有在 toUserId 为一个用户 Id 的时候有效。(可选)
         * @param  verifyBlacklist:是否过滤发送人黑名单列表,0 表示为不过滤、 1 表示为过滤,默认为 0 不过滤。(可选)
         * @param  isPersisted:当前版本有新的自定义消息,而老版本没有该自定义消息时,老版本客户端收到消息后是否进行存储,0 表示为不存储、 1 表示为存储,默认为 1 存储消息。(可选)
         * @param  isCounted:当前版本有新的自定义消息,而老版本没有该自定义消息时,老版本客户端收到消息后是否进行未读消息计数,0 表示为不计数、 1 表示为计数,默认为 1 计数,未读消息数增加 1。(可选)
         * @param  isIncludeSender:发送用户自已是否接收消息,0 表示为不接收,1 表示为接收,默认为 0 不接收。(可选)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut publishPrivate(String fromUserId, String[] toUserId, messages.Message message, String pushContent, String pushData, String count, int verifyBlacklist, int isPersisted, int isCounted, int isIncludeSender)
        {
            if (fromUserId == null)
            {
                throw new ArgumentNullException("Paramer 'fromUserId' is required");
            }

            if (toUserId == null)
            {
                throw new ArgumentNullException("Paramer 'toUserId' is required");
            }

            if (message.getType() == null)
            {
                throw new ArgumentNullException("Paramer 'ObjectName' is required");
            }

            if (message.ToString() == null)
            {
                throw new ArgumentNullException("Paramer 'Content' is required");
            }

            String postStr = "";

            postStr += "fromUserId=" + HttpUtility.UrlEncode(fromUserId == null ? "" : fromUserId, Encoding.UTF8) + "&";
            for (int i = 0; i < toUserId.Length; i++)
            {
                String child = toUserId[i];
                postStr += "toUserId=" + HttpUtility.UrlEncode(child, Encoding.UTF8) + "&";
            }

            postStr += "objectName=" + HttpUtility.UrlEncode(message.getType(), Encoding.UTF8) + "&";
            postStr += "content=" + HttpUtility.UrlEncode(message.ToString(), Encoding.UTF8) + "&";
            postStr += "pushContent=" + HttpUtility.UrlEncode(pushContent == null ? "" : pushContent, Encoding.UTF8) + "&";
            postStr += "pushData=" + HttpUtility.UrlEncode(pushData == null ? "" : pushData, Encoding.UTF8) + "&";
            postStr += "count=" + HttpUtility.UrlEncode(count == null ? "" : count, Encoding.UTF8) + "&";
            postStr += "verifyBlacklist=" + HttpUtility.UrlEncode(Convert.ToString(verifyBlacklist) == null ? "" : Convert.ToString(verifyBlacklist), Encoding.UTF8) + "&";
            postStr += "isPersisted=" + HttpUtility.UrlEncode(Convert.ToString(isPersisted) == null ? "" : Convert.ToString(isPersisted), Encoding.UTF8) + "&";
            postStr += "isCounted=" + HttpUtility.UrlEncode(Convert.ToString(isCounted) == null ? "" : Convert.ToString(isCounted), Encoding.UTF8) + "&";
            postStr += "isIncludeSender=" + HttpUtility.UrlEncode(Convert.ToString(isIncludeSender) == null ? "" : Convert.ToString(isIncludeSender), Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/private/publish.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #13
0
        /**
         * 消息历史记录下载地址获取 方法消息历史记录下载地址获取方法。获取 APP 内指定某天某小时内的所有会话消息记录的下载地址。(目前支持二人会话、讨论组、群组、聊天室、客服、系统通知消息历史记录下载)
         *
         * @param  date:指定北京时间某天某小时,格式为2014010101,表示:2014年1月1日凌晨1点。(必传)
         *
         * @return HistoryMessageReslut
         **/
        public HistoryMessageReslut getHistory(String date)
        {
            if (date == null)
            {
                throw new ArgumentNullException("Paramer 'date' is required");
            }

            String postStr = "";

            postStr += "date=" + HttpUtility.UrlEncode(date == null ? "" : date, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((HistoryMessageReslut)RongJsonUtil.JsonStringToObj <HistoryMessageReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/history.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #14
0
        /**
         * 发送单聊消息方法(一个用户向另外一个用户发送消息,单条消息最大 128k。每分钟最多发送 6000 条信息,每次发送用户上限为 1000 人,如:一次发送 1000 人时,示为 1000 条消息。)
         *
         * @param message 单聊消息
         *
         * @return ResponseResult
         * @throws Exception
         **/
        public async Task <ResponseResult> Send(PrivateMessage message)
        {
            if (null == message)
            {
                return(RongJsonUtil.JsonStringToObj <ResponseResult>("Paramer 'message' is required"));
            }

            string errMsg = CommonUtil.CheckFiled(message, PATH, CheckMethod.SEND);

            if (null != errMsg)
            {
                return(RongJsonUtil.JsonStringToObj <ResponseResult>(errMsg));
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("&fromUserId=").Append(HttpUtility.UrlEncode(message.SenderId, UTF8));

            for (int i = 0; i < message.TargetId.Length; i++)
            {
                string child = message.TargetId[i];
                if (null != child)
                {
                    sb.Append("&toUserId=").Append(HttpUtility.UrlEncode(child, UTF8));
                }
            }

            sb.Append("&objectName=").Append(HttpUtility.UrlEncode(message.Content.GetType(), UTF8));
            sb.Append("&content=").Append(HttpUtility.UrlEncode(message.Content.ToString(), UTF8));

            if (message.PushContent != null)
            {
                sb.Append("&pushContent=").Append(HttpUtility.UrlEncode(message.PushContent, UTF8));
            }

            if (message.PushData != null)
            {
                sb.Append("&pushData=").Append(HttpUtility.UrlEncode(message.PushData, UTF8));
            }

            if (message.Count != null)
            {
                sb.Append("&count=").Append(HttpUtility.UrlEncode(message.Count, UTF8));
            }

            if (0 != message.VerifyBlacklist)
            {
                sb.Append("&verifyBlacklist=").Append(HttpUtility.UrlEncode(message.VerifyBlacklist.ToString(), UTF8));
            }

            if (0 != message.IsPersisted)
            {
                sb.Append("&isPersisted=").Append(HttpUtility.UrlEncode(message.IsPersisted.ToString(), UTF8));
            }

            if (0 != message.IsCounted)
            {
                sb.Append("&isCounted=").Append(HttpUtility.UrlEncode(message.IsCounted.ToString(), UTF8));
            }

            if (0 != message.IsIncludeSender)
            {
                sb.Append("&isIncludeSender=").Append(HttpUtility.UrlEncode(message.IsIncludeSender.ToString(), UTF8));
            }

            string body = sb.ToString();

            if (body.IndexOf("&", StringComparison.OrdinalIgnoreCase) == 0)
            {
                body = body.Substring(1, body.Length - 1);
            }

            string result = await RongHttpClient.ExecutePost(AppKey, AppSecret, body,
                                                             RongCloud.ApiHostType.Type + "/message/private/publish.json", "application/x-www-form-urlencoded");

            return(RongJsonUtil.JsonStringToObj <ResponseResult>(
                       CommonUtil.GetResponseByCode(PATH, CheckMethod.PUBLISH, result)));
        }
Example #15
0
        /**
         * 查询被禁言群成员方法
         *
         * @param  groupId:群组Id。(必传)
         *
         * @return ListGagGroupUserReslut
         **/
        public ListGagGroupUserReslut lisGagUser(String groupId)
        {
            if (groupId == null)
            {
                throw new ArgumentNullException("Paramer 'groupId' is required");
            }

            String postStr = "";

            postStr += "groupId=" + HttpUtility.UrlEncode(groupId == null ? "" : groupId, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((ListGagGroupUserReslut)RongJsonUtil.JsonStringToObj <ListGagGroupUserReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/group/user/gag/list.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #16
0
        /**
         * 查询聊天室内用户方法
         *
         * @param  chatroomId:要查询的聊天室 ID。(必传)
         * @param  count:要获取的聊天室成员数,上限为 500 ,超过 500 时最多返回 500 个成员。(必传)
         * @param  order:加入聊天室的先后顺序, 1 为加入时间正序, 2 为加入时间倒序。(必传)
         *
         * @return ChatroomUserQueryReslut
         **/
        public ChatroomUserQueryReslut queryUser(String chatroomId, String count, String order)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            if (count == null)
            {
                throw new ArgumentNullException("Paramer 'count' is required");
            }

            if (order == null)
            {
                throw new ArgumentNullException("Paramer 'order' is required");
            }

            String postStr = "";

            postStr += "chatroomId=" + HttpUtility.UrlEncode(chatroomId == null ? "" : chatroomId, Encoding.UTF8) + "&";
            postStr += "count=" + HttpUtility.UrlEncode(count == null ? "" : count, Encoding.UTF8) + "&";
            postStr += "order=" + HttpUtility.UrlEncode(order == null ? "" : order, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((ChatroomUserQueryReslut)RongJsonUtil.JsonStringToObj <ChatroomUserQueryReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/user/query.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #17
0
        /**
         * 同步用户所属群组方法(当第一次连接融云服务器时,需要向融云服务器提交 userId 对应的用户当前所加入的所有群组,此接口主要为防止应用中用户群信息同融云已知的用户所属群信息不同步。)
         *
         * @param  userId:被同步群信息的用户 Id。(必传)
         * @param  groupInfo:该用户的群信息,如群 Id 已经存在,则不会刷新对应群组名称,如果想刷新群组名称请调用刷新群组信息方法。
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut sync(String userId, GroupInfo[] groupInfo)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            if (groupInfo == null)
            {
                throw new ArgumentNullException("Paramer 'groupInfo' is required");
            }

            String postStr = "";

            postStr += "userId=" + HttpUtility.UrlEncode(userId == null ? "" : userId, Encoding.UTF8) + "&";
            if (groupInfo != null)
            {
                for (int i = 0; i < groupInfo.Length; i++)
                {
                    String id   = HttpUtility.UrlEncode(groupInfo[i].getId(), Encoding.UTF8);
                    String name = HttpUtility.UrlEncode(groupInfo[i].getName(), Encoding.UTF8);
                    postStr += "group[" + id + "]=" + name + "&";
                }
            }
            postStr = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/group/sync.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #18
0
        /**
         * 创建聊天室方法
         *
         * @param  chatRoomInfo:id:要创建的聊天室的id;name:要创建的聊天室的name。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut create(ChatRoomInfo[] chatRoomInfo)
        {
            if (chatRoomInfo == null)
            {
                throw new ArgumentNullException("Paramer 'chatRoomInfo' is required");
            }

            String postStr = "";

            if (chatRoomInfo != null)
            {
                for (int i = 0; i < chatRoomInfo.Length; i++)
                {
                    String id   = HttpUtility.UrlEncode(chatRoomInfo[i].getId(), Encoding.UTF8);
                    String name = HttpUtility.UrlEncode(chatRoomInfo[i].getName(), Encoding.UTF8);
                    postStr += "chatroom[" + id + "]=" + name + "&";
                }
            }
            postStr = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/create.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #19
0
        /**
         * 发送短信验证码方法。
         *
         * @param  mobile:接收短信验证码的目标手机号,每分钟同一手机号只能发送一次短信验证码,同一手机号 1 小时内最多发送 3 次。(必传)
         * @param  templateId:短信模板 Id,在开发者后台->短信服务->服务设置->短信模版中获取。(必传)
         * @param  region:手机号码所属国家区号,目前只支持中图区号 86)
         * @param  verifyId:图片验证标识 Id ,开启图片验证功能后此参数必传,否则可以不传。在获取图片验证码方法返回值中获取。
         * @param  verifyCode:图片验证码,开启图片验证功能后此参数必传,否则可以不传。
         *
         * @return SMSSendCodeReslut
         **/
        public SMSSendCodeReslut sendCode(String mobile, String templateId, String region, String verifyId, String verifyCode)
        {
            if (mobile == null)
            {
                throw new ArgumentNullException("Paramer 'mobile' is required");
            }

            if (templateId == null)
            {
                throw new ArgumentNullException("Paramer 'templateId' is required");
            }

            if (region == null)
            {
                throw new ArgumentNullException("Paramer 'region' is required");
            }

            String postStr = "";

            postStr += "mobile=" + HttpUtility.UrlEncode(mobile == null ? "" : mobile, Encoding.UTF8) + "&";
            postStr += "templateId=" + HttpUtility.UrlEncode(templateId == null ? "" : templateId, Encoding.UTF8) + "&";
            postStr += "region=" + HttpUtility.UrlEncode(region == null ? "" : region, Encoding.UTF8) + "&";
            postStr += "verifyId=" + HttpUtility.UrlEncode(verifyId == null ? "" : verifyId, Encoding.UTF8) + "&";
            postStr += "verifyCode=" + HttpUtility.UrlEncode(verifyCode == null ? "" : verifyCode, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((SMSSendCodeReslut)RongJsonUtil.JsonStringToObj <SMSSendCodeReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDSMSURI + "/sendCode.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #20
0
        /**
         * 添加聊天室消息优先级方法
         *
         * @param  objectName:低优先级的消息类型,每次最多提交 5 个,设置的消息类型最多不超过 20 个。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut addPriority(String[] objectName)
        {
            if (objectName == null)
            {
                throw new ArgumentNullException("Paramer 'objectName' is required");
            }

            String postStr = "";

            for (int i = 0; i < objectName.Length; i++)
            {
                String child = objectName[i];
                postStr += "objectName=" + HttpUtility.UrlEncode(child, Encoding.UTF8) + "&";
            }

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/message/priority/add.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #21
0
        /**
         * 验证码验证方法
         *
         * @param  sessionId:短信验证码唯一标识,在发送短信验证码方法,返回值中获取。(必传)
         * @param  code:短信验证码内容。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut verifyCode(String sessionId, String code)
        {
            if (sessionId == null)
            {
                throw new ArgumentNullException("Paramer 'sessionId' is required");
            }

            if (code == null)
            {
                throw new ArgumentNullException("Paramer 'code' is required");
            }

            String postStr = "";

            postStr += "sessionId=" + HttpUtility.UrlEncode(sessionId == null ? "" : sessionId, Encoding.UTF8) + "&";
            postStr += "code=" + HttpUtility.UrlEncode(code == null ? "" : code, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDSMSURI + "/verifyCode.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #22
0
        /**
         * 查询聊天室信息方法
         *
         * @param  chatroomId:要查询的聊天室id(必传)
         *
         * @return ChatroomQueryReslut
         **/
        public ChatroomQueryReslut query(String[] chatroomId)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            String postStr = "";

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

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

            return((ChatroomQueryReslut)RongJsonUtil.JsonStringToObj <ChatroomQueryReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/query.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #23
0
        /**
         * 添加 Push 标签方法
         *
         * @param  userTag:用户标签。
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut setUserPushTag(UserTag userTag)
        {
            if (userTag == null)
            {
                throw new ArgumentNullException("Paramer 'userTag' is required");
            }

            String postStr = "";

            postStr = JsonConvert.SerializeObject(userTag);
            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/tag/set.json", postStr, "application/json")));
        }
Example #24
0
        /**
         * 封禁用户方法(每秒钟限 100 次)
         *
         * @param  userId:用户 Id。(必传)
         * @param  minute:封禁时长,单位为分钟,最大值为43200分钟。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut block(String userId, int minute)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            if (minute == null)
            {
                throw new ArgumentNullException("Paramer 'minute' is required");
            }

            String postStr = "";

            postStr += "userId=" + HttpUtility.UrlEncode(userId == null ? "" : userId, Encoding.UTF8) + "&";
            postStr += "minute=" + HttpUtility.UrlEncode(Convert.ToString(minute) == null ? "" : Convert.ToString(minute), Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/block.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #25
0
        /**
         * 广播消息方法(fromuserid 和 message为null即为不落地的push)
         *
         * @param  pushMessage:json数据
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut broadcastPush(PushMessage pushMessage)
        {
            if (pushMessage == null)
            {
                throw new ArgumentNullException("Paramer 'pushMessage' is required");
            }

            String postStr = "";

            postStr = JsonConvert.SerializeObject(pushMessage);
            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/push.json", postStr, "application/json")));
        }
Example #26
0
        /**
         * 添加用户到黑名单方法(每秒钟限 100 次)
         *
         * @param  userId:用户 Id。(必传)
         * @param  blackUserId:被加到黑名单的用户Id。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut addBlacklist(String userId, String blackUserId)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            if (blackUserId == null)
            {
                throw new ArgumentNullException("Paramer 'blackUserId' is required");
            }

            String postStr = "";

            postStr += "userId=" + HttpUtility.UrlEncode(userId == null ? "" : userId, Encoding.UTF8) + "&";
            postStr += "blackUserId=" + HttpUtility.UrlEncode(blackUserId == null ? "" : blackUserId, Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/blacklist/add.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #27
0
        /**
         * 发送聊天室消息方法(一个用户向聊天室发送消息,单条消息最大 128k。每秒钟限 100 次。)
         *
         * @param  fromUserId:发送人用户 Id。(必传)
         * @param  toChatroomId:接收聊天室Id,提供多个本参数可以实现向多个聊天室发送消息。(必传)
         * @param  txtMessage:发送消息内容(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut publishChatroom(String fromUserId, String[] toChatroomId, messages.Message message)
        {
            if (fromUserId == null)
            {
                throw new ArgumentNullException("Paramer 'fromUserId' is required");
            }

            if (toChatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'toChatroomId' is required");
            }

            if (message.getType() == null)
            {
                throw new ArgumentNullException("Paramer 'ObjectName' is required");
            }

            if (message.ToString() == null)
            {
                throw new ArgumentNullException("Paramer 'Content' is required");
            }

            String postStr = "";

            postStr += "fromUserId=" + HttpUtility.UrlEncode(fromUserId == null ? "" : fromUserId, Encoding.UTF8) + "&";
            for (int i = 0; i < toChatroomId.Length; i++)
            {
                String child = toChatroomId[i];
                postStr += "toChatroomId=" + HttpUtility.UrlEncode(child, Encoding.UTF8) + "&";
            }

            postStr += "objectName=" + HttpUtility.UrlEncode(message.getType(), Encoding.UTF8) + "&";
            postStr += "content=" + HttpUtility.UrlEncode(message.ToString(), Encoding.UTF8) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/chatroom/publish.json", postStr, "application/x-www-form-urlencoded")));
        }