Beispiel #1
0
        /// <summary>
        /// 删除成员
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public UserCommResult DeleteUser(string accessToken, string userid)
        {
            string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token={0}&userid={1}";
            var    url       = string.Format(urlFormat, accessToken, userid);
            string resultMsg = HttpHelper.HttpGet(url, "");
            //反序列化
            UserCommResult result = JsonConvert.DeserializeObject <UserCommResult>(resultMsg);

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 批量删除成员
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public UserCommResult BatchDeleteUser(string accessToken, Useridlist usridlst)
        {
            string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete?access_token={0}";
            var    url       = string.Format(urlFormat, accessToken);

            string postData = JsonConvert.SerializeObject(usridlst);
            //post
            string resultMsg = HttpHelper.HttpPost(url, postData);

            //反序列化
            UserCommResult result = JsonConvert.DeserializeObject <UserCommResult>(resultMsg);

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 更新成员
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public UserCommResult UpdateUser(string accessToken, UserJsonAll user)
        {
            string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={0}";
            var    data      = new
            {
                userid     = user.userid,
                name       = user.name,
                department = user.department,
                position   = user.position,
                mobile     = user.mobile,
                gender     = user.gender,
                email      = user.email,
                weixinid   = user.weixinid
            };
            var    url      = string.Format(urlFormat, accessToken);
            string postData = JsonConvert.SerializeObject(data);
            //post
            string resultMsg = HttpHelper.HttpPost(url, postData);
            //反序列化
            UserCommResult result = JsonConvert.DeserializeObject <UserCommResult>(resultMsg);

            return(result);
        }