/**
         * 获取 Token 方法
         *
         * @param  userId:用户 Id,最大长度 64 字节.是用户在 App 中的唯一标识码,必须保证在同一个 App 内不重复,重复的用户 Id 将被当作是同一用户。(必传)
         * @param  name:用户名称,最大长度 128 字节.用来在 Push 推送时显示用户的名称.用户名称,最大长度 128 字节.用来在 Push 推送时显示用户的名称。(必传)
         * @param  portraitUri:用户头像 URI,最大长度 1024 字节.用来在 Push 推送时显示用户的头像。(必传)
         *
         * @return TokenReslut
         **/
        public async Task <TokenReslut> getTokenAsync(String userId, String name, String portraitUri)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

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

            if (portraitUri == null)
            {
                throw new ArgumentNullException("Paramer 'portraitUri' 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();
            string result     = await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/getToken.json", postStr, "application/x-www-form-urlencoded");

            return((TokenReslut)RongJsonUtil.JsonStringToObj <TokenReslut>(result));
        }
        /**
         * 检查用户在线状态 方法
         *
         * @param  userId:用户 Id,最大长度 64 字节。是用户在 App 中的唯一标识码,必须保证在同一个 App 内不重复,重复的用户 Id 将被当作是同一用户。(必传)
         *
         * @return CheckOnlineReslut
         **/
        public async Task <CheckOnlineReslut> checkOnlineAsync(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((CheckOnlineReslut)RongJsonUtil.JsonStringToObj <CheckOnlineReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/checkOnline.json", postStr, "application/x-www-form-urlencoded")));
        }
        /**
         * 获取被封禁用户方法(每秒钟限 100 次)
         *
         *
         * @return QueryBlockUserReslut
         **/
        public async Task <QueryBlockUserReslut> queryBlockAsync()
        {
            String postStr    = "";
            var    rongClient = new RongHttpClient();

            return((QueryBlockUserReslut)RongJsonUtil.JsonStringToObj <QueryBlockUserReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/block/query.json", postStr, "application/x-www-form-urlencoded")));
        }
        /**
         * 发送单聊消息方法(一个用户向另外一个用户发送消息,单条消息最大 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。(可选)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> publishPrivateAsync(String fromUserId, String[] toUserId, VoiceMessage message, String pushContent, String pushData, String count, int verifyBlacklist, int isPersisted, int isCounted)
        {
            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) + "&";
            for (int i = 0; i < toUserId.Length; i++)
            {
                String child = toUserId[i];
                postStr += "toUserId=" + HttpUtility.UrlEncode(child) + "&";
            }

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/message/private/publish.json", postStr, "application/x-www-form-urlencoded")));
        }
        /**
         * 封禁用户方法(每秒钟限 100 次)
         *
         * @param  userId:用户 Id。(必传)
         * @param  minute:封禁时长,单位为分钟,最大值为43200分钟。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> blockAsync(String userId, int minute)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

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

            String postStr = "";

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/block.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #6
0
        /**
         * 添加 Push 标签方法
         *
         * @param  userTag:用户标签。
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> setUserPushTagAsync(UserTag userTag)
        {
            if (userTag == null)
            {
                throw new ArgumentNullException("Paramer 'userTag' is required");
            }

            String postStr = "";

            postStr = JsonConvert.SerializeObject(userTag);
            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/tag/set.json", postStr, "application/json")));
        }
Example #7
0
        /**
         * 发送短信验证码方法。
         *
         * @param  mobile:接收短信验证码的目标手机号,每分钟同一手机号只能发送一次短信验证码,同一手机号 1 小时内最多发送 3 次。(必传)
         * @param  templateId:短信模板 Id,在开发者后台->短信服务->服务设置->短信模版中获取。(必传)
         * @param  region:手机号码所属国家区号,目前只支持中图区号 86)
         * @param  verifyId:图片验证标识 Id ,开启图片验证功能后此参数必传,否则可以不传。在获取图片验证码方法返回值中获取。
         * @param  verifyCode:图片验证码,开启图片验证功能后此参数必传,否则可以不传。
         *
         * @return SMSSendCodeReslut
         **/
        public async Task <SMSSendCodeReslut> sendCodeAsync(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) + "&";
            postStr += "templateId=" + HttpUtility.UrlEncode(templateId == null ? "" : templateId) + "&";
            postStr += "region=" + HttpUtility.UrlEncode(region == null ? "" : region) + "&";
            postStr += "verifyId=" + HttpUtility.UrlEncode(verifyId == null ? "" : verifyId) + "&";
            postStr += "verifyCode=" + HttpUtility.UrlEncode(verifyCode == null ? "" : verifyCode) + "&";
            postStr  = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((SMSSendCodeReslut)RongJsonUtil.JsonStringToObj <SMSSendCodeReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDSMSURI + "/sendCode.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #8
0
        /**
         * 添加敏感词方法(设置敏感词后,App 中用户不会收到含有敏感词的消息内容,默认最多设置 50 个敏感词。)
         *
         * @param  word:敏感词,最长不超过 32 个字符。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> addAsync(String word)
        {
            if (word == null)
            {
                throw new ArgumentNullException("Paramer 'word' is required");
            }

            String postStr = "";

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/wordfilter/add.json", postStr, "application/x-www-form-urlencoded")));
        }
Example #9
0
        /**
         * 创建聊天室方法
         *
         * @param  chatRoomInfo:id:要创建的聊天室的id;name:要创建的聊天室的name。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> createAsync(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());
                    String name = HttpUtility.UrlEncode(chatRoomInfo[i].getName());
                    postStr += "chatroom[" + id + "]=" + name + "&";
                }
            }
            postStr = postStr.Substring(0, postStr.LastIndexOf('&'));

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/chatroom/create.json", postStr, "application/x-www-form-urlencoded")));
        }
        /**
         * 创建群组方法(创建群组,并将用户加入该群组,用户将可以收到该群的消息,同一用户最多可加入 500 个群,每个群最大至 3000 人,App 内的群组数量没有限制.注:其实本方法是加入群组方法 /group/join 的别名。)
         *
         * @param  userId:要加入群的用户 Id。(必传)
         * @param  groupId:创建群组 Id。(必传)
         * @param  groupName:群组 Id 对应的名称。(必传)
         *
         * @return CodeSuccessReslut
         **/
        public async Task <CodeSuccessReslut> createAsync(String[] userId, String groupId, String groupName)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("Paramer 'userId' is required");
            }

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

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

            String postStr = "";

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

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

            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(await rongClient.ExecutePostAsync(appKey, appSecret, RongCloud.RONGCLOUDURI + "/group/create.json", postStr, "application/x-www-form-urlencoded")));
        }