• 章节:26
  • 访问:1167
  • 时长:00:13:18
  • 日期:2020-01-01 09:35

开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。

接口调用请求说明

http请求方式: POST

http://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN

            public static string DeserializeJson(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }
            public static string HttpPost(string Url,string postDataStr)
        {
            WebRequest request = WebRequest.Create(Url);
            request.Method = "POST";
            request.ContentType = "application/json";
            byte[] buf = Encoding.UTF8.GetBytes(postDataStr);
            byte[] byteArray = System.Text.Encoding.Default.GetBytes(postDataStr);
            request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
            request.GetRequestStream().Write(buf, 0, buf.Length);
            WebResponse response = request.GetResponse();
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();
            return retString;
        }
            private void Button_Click(object sender, RoutedEventArgs e)
        {
            UserOpenidInfo userInfos = UserHelper.GetUserInfos();
            var param = new { user_list = userInfos.data.openid.Select(m=>new { openid=m }) };
            var res =HttpHelper.HttpPost("http://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=" + TokenHelper.GetTokenInfo().access_token, JsonHelper.SerializeObject(param));
        }