Ejemplo n.º 1
0
        public static WechatJsTicket GetJsapi_ticket(string access_token, string userAgent)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", access_token);

            HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(url, null, userAgent, null);

            //Stream stream = response.GetResponseStream();
            //StreamReader sr = new StreamReader(stream);
            //string result = sr.ReadToEnd();
            string         result = HttpWebResponseUtility.HttpResponseToString(response);
            WechatJsTicket ticket = JsonConvert.DeserializeObject <WechatJsTicket>(result);

            return(ticket);
        }
Ejemplo n.º 2
0
        public static WechatUserInfo GetUserInfo(string access_token, string userAgent, string openid)
        {
            WechatUserInfo userinfo = new WechatUserInfo();

            string url = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN", access_token, openid);

            HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(url, null, userAgent, null);

            string result = HttpWebResponseUtility.HttpResponseToString(response);

            userinfo = JsonConvert.DeserializeObject <WechatUserInfo>(result);

            return(userinfo);
        }