Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            GetAppInof getappinfo = GetAgent_info(IsExistAccess_Token(this.textBox_corpid.Text, this.textBox_corpsecret.Text), "1000003");

            this.textBox1.Text  = "name:" + getappinfo.name;
            this.textBox1.Text += "\r\n allow_userinfos:\r\n";
            int n = getappinfo.allow_userinfos.user.Count;

            for (int i = 0; i < n; i++)
            {
                string username = GetUser(IsExistAccess_Token(this.textBox_corpid.Text, this.textBox_corpsecret.Text), getappinfo.allow_userinfos.user[i].userid).name;
                this.textBox1.Text += "[user" + (i + 1).ToString() + ":" + getappinfo.allow_userinfos.user[i].userid + ":" + username + "]\r\n";
            }
        }
Exemple #2
0
        //获取应用信息
        private static GetAppInof GetAgent_info(string access_token, string agentid)
        {
            string         strUrl = "https://qyapi.weixin.qq.com/cgi-bin/agent/get?access_token=" + access_token + "&agentid=" + agentid;
            GetAppInof     mode   = new GetAppInof();
            HttpWebRequest req    = (HttpWebRequest)HttpWebRequest.Create(strUrl);

            req.Method = "GET";
            using (WebResponse wr = req.GetResponse())
            {
                HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
                StreamReader    reader     = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                string          content    = reader.ReadToEnd();// 赋值
                GetAppInof      token      = new GetAppInof();
                token                = Newtonsoft.Json.JsonConvert.DeserializeObject <GetAppInof>(content);
                mode.name            = token.name;
                mode.square_logo_url = token.square_logo_url;
                mode.description     = token.description;
                mode.allow_userinfos = token.allow_userinfos;
            }
            return(mode);
        }