Пример #1
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 String 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);

            return client.ExecutePost();
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="chatroomInfo">chatroom[id10001]=name1001</param>
        /// <returns></returns>
        public static String 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);

            return client.ExecutePost();
        }
Пример #3
0
        /**
         * 解散 群组
         */
        public static String DismissGroup(String appkey, String appSecret, String userId, String groupId)
        {
            Dictionary<String, String> dicList = new Dictionary<String, String>();
            dicList.Add("userId", userId);
            dicList.Add("groupId", groupId);

            String postStr = buildQueryStr(dicList);

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

            return client.ExecutePost();
        }
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="chatroomIdInfo">chatroomId=id1001</param>
        /// <returns></returns>
        public static String DestroyChatroom(String appkey, String appSecret, String[] chatroomIdInfo)
        {
            String postStr = null;

            postStr = buildParamStr(chatroomIdInfo);

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

            return client.ExecutePost();
        }
Пример #5
0
        /**
         * 同步群组
         */
        public static String syncGroup(String appkey, String appSecret, String userId, String[] groupId, String[] groupName)
        {
            String postStr = "userId=" + userId + "&";
            String id, name;

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

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

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

            return client.ExecutePost();
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appSecret"></param>
        /// <param name="fromUserId"></param>
        /// <param name="toUserId"></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 String PublishMessage(String appkey, String appSecret, String fromUserId, String toUserId, String objectName, String content)
        {
            Dictionary<String, String> dicList = new Dictionary<String, String>();
            dicList.Add("fromUserId", fromUserId);
            dicList.Add("toUserId", toUserId);
            dicList.Add("objectName", objectName);
            dicList.Add("content", content);

            String postStr = buildQueryStr(dicList);

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

            return client.ExecutePost();
        }
Пример #7
0
        /**
         * 获取 token
         */
        public static String GetToken(String appkey, String appSecret, String userId, String name, String portraitUri)
        {
            Dictionary<String, String> dicList = new Dictionary<String, String>();
            dicList.Add("userId", userId);
            dicList.Add("name", name);
            dicList.Add("portraitUri", portraitUri);

            String postStr = buildQueryStr(dicList);

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

            return client.ExecutePost();
        }