Пример #1
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")));
        }
Пример #2
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")));
        }
Пример #3
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" ));
		}
Пример #4
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")));
        }
Пример #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" ));
		}
Пример #6
0
        /**
         * 获取被封禁用户方法(每秒钟限 100 次)
         *
         *
         * @return QueryBlockUserResult
         **/
        public BlockUserResult GetList()
        {
            StringBuilder sb   = new StringBuilder();
            String        body = sb.ToString();

            if (body.IndexOf("&") == 0)
            {
                body = body.Substring(1, body.Length - 1);
            }
            String result = RongHttpClient.ExecutePost(appKey, appSecret, body, RongCloud.ApiHostType.Type + "/user/block/query.json", "application/x-www-form-urlencoded");

            return((BlockUserResult)RongJsonUtil.JsonStringToObj <BlockUserResult>(CommonUtil.GetResponseByCode(PATH, CheckMethod.GETLIST, result)));
        }
Пример #7
0
        /**
         * 添加敏感词方法(设置敏感词后,App 中用户不会收到含有敏感词的消息内容,默认最多设置 50 个敏感词。)
         *
         * @param  word:敏感词,最长不超过 32 个字符。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut add(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/add.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #8
0
        /**
         * 消息历史记录删除方法(删除 APP 内指定某天某小时内的所有会话消息记录。调用该接口返回成功后,date参数指定的某小时的消息记录文件将在随后的5-10分钟内被永久删除。)
         *
         * @param  date:指定北京时间某天某小时,格式为2014010101,表示:2014年1月1日凌晨1点。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut deleteMessage(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((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/history/delete.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #9
0
        /**
         * 检查用户在线状态 方法
         *
         * @param  userId:用户 Id,最大长度 64 字节。是用户在 App 中的唯一标识码,必须保证在同一个 App 内不重复,重复的用户 Id 将被当作是同一用户。(必传)
         *
         * @return CheckOnlineReslut
         **/
        public CheckOnlineReslut checkOnline(String userId)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            String postStr = "";

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

            return((CheckOnlineReslut)RongJsonUtil.JsonStringToObj <CheckOnlineReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/checkOnline.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #10
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")));
        }
Пример #11
0
        /**
         * 获取图片验证码方法
         *
         * @param  appKey:应用Id
         *
         * @return SMSImageCodeReslut
         **/
        public SMSImageCodeReslut getImageCode(String appKey)
        {
            if (appKey == null)
            {
                throw new ArgumentNullException("Paramer 'appKey' is required");
            }

            String postStr = "";

            postStr = RongCloud.RONGCLOUDSMSURI + "/getImgCode.json";
            postStr = postStr + ("?appKey=") + (HttpUtility.UrlEncode(appKey == null ? "" : appKey, Encoding.UTF8));

            return((SMSImageCodeReslut)RongJsonUtil.JsonStringToObj <SMSImageCodeReslut>(RongHttpClient.ExecuteGet(postStr)));
        }
Пример #12
0
        /**
         * 查询被禁言聊天室成员方法
         *
         * @param  chatroomId:聊天室 Id。(必传)
         *
         * @return ListGagChatroomUserReslut
         **/
        public async Task <ListGagChatroomUserReslut> ListGagUser(String chatroomId)
        {
            if (chatroomId == null)
            {
                throw new ArgumentNullException("Paramer 'chatroomId' is required");
            }

            String postStr = "";

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

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

            String postStr = "";

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

            return((HistoryMessageReslut)RongJsonUtil.JsonStringToObj <HistoryMessageReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/history.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #14
0
        /**
         * 查询群成员方法
         *
         * @param  groupId:群组Id。(必传)
         *
         * @return GroupUserQueryReslut
         **/
        public async Task <GroupUserQueryReslut> queryUserAsync(String groupId)
        {
            if (groupId == null)
            {
                throw new ArgumentNullException("Paramer 'groupId' is required");
            }

            String postStr = "";

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

            return((GroupUserQueryReslut)RongJsonUtil.JsonStringToObj <GroupUserQueryReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/group/user/query.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #15
0
        /**
         * 获取某用户的黑名单列表方法(每秒钟限 100 次)
         *
         * @param  userId:用户 Id。(必传)
         *
         * @return QueryBlacklistUserReslut
         **/
        public async Task <QueryBlacklistUserReslut> queryBlacklistAsync(String userId)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

            String postStr = "";

            postStr += "userId=" + HttpUtility.UrlEncode(userId == null ? "" : userId) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));
            var rongClient = new RongHttpClient();

            return((QueryBlacklistUserReslut)RongJsonUtil.JsonStringToObj <QueryBlacklistUserReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/blacklist/query.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #16
0
        /**
         * 查询敏感词列表方法
         *
         *
         * @return ListWordfilterResult
         **/
        public async Task <ListWordfilterResult> GetList()
        {
            StringBuilder sb   = new StringBuilder();
            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 + "/wordfilter/list.json", "application/x-www-form-urlencoded");

            return(RongJsonUtil.JsonStringToObj <ListWordfilterResult>(
                       CommonUtil.GetResponseByCode(PATH, CheckMethod.GETLIST, result)));
        }
Пример #17
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" ));
		}
Пример #18
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" ));
		}
Пример #19
0
        /**
         * 批量设置用户标签
         */
        public ResponseResult BatchSet(TagModel tagModel)
        {
            String message = CommonUtil.CheckFiled(tagModel, PATH, CheckMethod.TAG_BATCH_SET);

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

            String body = RongJsonUtil.ObjToJsonString(tagModel);

            String result = RongHttpClient.ExecutePost(appKey, appSecret, body,
                                                       rongCloud.ApiHostType.Type + "/user/tag/batch/set.json", "application/json");

            return((ResponseResult)RongJsonUtil.JsonStringToObj <ResponseResult>(CommonUtil.GetResponseByCode(PATH, CheckMethod.TAG_BATCH_SET, result)));
        }
Пример #20
0
        /**
         * 刷新用户信息方法
         *
         * @param  userId:用户 Id,最大长度 64 字节.是用户在 App 中的唯一标识码,必须保证在同一个 App 内不重复,重复的用户 Id 将被当作是同一用户。(必传)
         * @param  name:用户名称,最大长度 128 字节。用来在 Push 推送时,显示用户的名称,刷新用户名称后 5 分钟内生效。(可选,提供即刷新,不提供忽略)
         * @param  portraitUri:用户头像 URI,最大长度 1024 字节。用来在 Push 推送时显示。(可选,提供即刷新,不提供忽略)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> refreshAsync(String userId, String name, String portraitUri)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }
            String postStr = "";

            postStr += "userId=" + HttpUtility.UrlEncode(userId == null ? "" : userId) + "&";
            postStr += "name=" + HttpUtility.UrlEncode(name == null ? "" : name) + "&";
            postStr += "portraitUri=" + HttpUtility.UrlEncode(portraitUri == null ? "" : portraitUri) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));
            var rongClient = new RongHttpClient();

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/refresh.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #21
0
        /**
         * 推送
         *
         * @param push 推送数据
         * @return PushResult
         **/
        public PushResult Send(PushModel push)
        {
            // 需要校验的字段
            String message = CommonUtil.CheckFiled(push, PATH, CheckMethod.PUSH);

            if (null != message)
            {
                return((PushResult)RongJsonUtil.JsonStringToObj <PushResult>(message));
            }

            String body = RongJsonUtil.ObjToJsonString(push);

            String result = RongHttpClient.ExecutePost(appKey, appSecret, body,
                                                       RongCloud.ApiHostType.Type + "/push.json", "application/json");

            return((PushResult)RongJsonUtil.JsonStringToObj <PushResult>(CommonUtil.GetResponseByCode(PATH, CheckMethod.BROADCAST, result)));
        }
Пример #22
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" ));
		}
Пример #23
0
        /**
         * 广播
         *
         * @param broadcast 广播数据
         * @return PushResult
         **/
        public async Task <PushResult> Send(BroadcastModel broadcast)
        {
            // 需要校验的字段
            string message = CommonUtil.CheckFiled(broadcast, PATH, CheckMethod.BROADCAST);

            if (null != message)
            {
                return(RongJsonUtil.JsonStringToObj <PushResult>(message));
            }

            string body = RongJsonUtil.ObjToJsonString(broadcast);

            string result = await RongHttpClient.ExecutePost(appKey, appSecret, body,
                                                             RongCloud.ApiHostType.Type + "/push.json", "application/json");

            return(RongJsonUtil.JsonStringToObj <PushResult>(CommonUtil.GetResponseByCode(PATH, CheckMethod.BROADCAST,
                                                                                          result)));
        }
Пример #24
0
        /**
         * 设置用户标签
         */
        public async Task <ResponseResult> Set(TagModel tagModel)
        {
            //需要校验的字段
            string message = CommonUtil.CheckFiled(tagModel, PATH, CheckMethod.TAG_SET);

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

            string body = RongJsonUtil.ObjToJsonString(tagModel);

            string result = await RongHttpClient.ExecutePost(appKey, appSecret, body,
                                                             RongCloud.ApiHostType.Type + "/user/tag/set.json", "application/json");

            return(RongJsonUtil.JsonStringToObj <ResponseResult>(
                       CommonUtil.GetResponseByCode(PATH, CheckMethod.TAG_SET, result)));
        }
Пример #25
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, VoiceMessage 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")));
        }
Пример #26
0
        /**
         * 发送广播消息方法(发送消息给一个应用下的所有注册用户,如用户未在线会对满足条件(绑定手机终端)的用户发送 Push 信息,单条消息最大 128k,会话类型为 SYSTEM。每小时只能发送 2 次,每天最多发送 3 次。)
         * 该功能开发环境下可免费使用。生产环境下,您需要登录开发者后台,在“应用/IM 服务/高级功能设置”中开通公有云专业版后,在“广播消息和推送”中,开启后才能使用
         *
         * @param message 消息体
         *
         * @return ResponseResult
         * @throws Exception
         **/
        public async Task <ResponseResult> Broadcast(BroadcastMessage message)
        {
            string errMsg = CommonUtil.CheckFiled(message, PATH1, CheckMethod.BROADCAST);

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

            StringBuilder sb = new StringBuilder();

            sb.Append("&fromUserId=").Append(HttpUtility.UrlEncode(message.SenderId, 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.Os != null)
            {
                sb.Append("&os=").Append(HttpUtility.UrlEncode(message.Os, 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/broadcast.json", "application/x-www-form-urlencoded");

            return(RongJsonUtil.JsonStringToObj <ResponseResult>(
                       CommonUtil.GetResponseByCode(PATH1, CheckMethod.BROADCAST, result)));
        }
Пример #27
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")));
        }
Пример #28
0
        /**
         * 销毁聊天室方法
         *
         * @param  chatroomId:要销毁的聊天室 Id。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> destroyAsync(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) + "&";
            }

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/destroy.json", postStr, "application/x-www-form-urlencoded")));
        }
Пример #29
0
        /// <summary>
        /// 融云-消息撤回
        /// </summary>
        public ReturnValueModel MessageRecall(RecallMessageInputDto inputDto, WorkUser workUser)
        {
            ReturnValueModel rvm = new ReturnValueModel();

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

            StringBuilder sb = new StringBuilder();

            sb.Append("&conversationType=").Append(HttpUtility.UrlEncode("1", Encoding.UTF8));
            sb.Append("&fromUserId=").Append(HttpUtility.UrlEncode(inputDto.SenderId.ToString(), Encoding.UTF8));
            sb.Append("&targetId=").Append(HttpUtility.UrlEncode(inputDto.TargetId.ToString(), Encoding.UTF8));
            sb.Append("&messageUID=").Append(HttpUtility.UrlEncode(inputDto.UId.ToString(), Encoding.UTF8));
            sb.Append("&sentTime=").Append(HttpUtility.UrlEncode(inputDto.SentTime.ToString(), Encoding.UTF8));
            String body = sb.ToString();

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

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

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

            if (res.Code == 200)
            {
                rvm.Msg     = "success";
                rvm.Success = true;
                rvm.Result  = res;
                return(rvm);
            }
            else
            {
                rvm.Msg     = "消息撤回失败";
                rvm.Success = false;
                rvm.Result  = result;
                return(rvm);
            }
        }
Пример #30
0
        /**
         * 验证码验证方法
         *
         * @param  sessionId:短信验证码唯一标识,在发送短信验证码方法,返回值中获取。(必传)
         * @param  code:短信验证码内容。(必传)
         *
         * @return SMSVerifyCodeResult
         **/
        public SMSVerifyCodeResult 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((SMSVerifyCodeResult)RongJsonUtil.JsonStringToObj <SMSVerifyCodeResult>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDSMSURI + "/verifyCode.json", postStr, "application/x-www-form-urlencoded")));
        }