用.net开发微信如何获取AccessToken介绍
- 微信应用
- 2024-10-14 09:14:01
用.net开发微信如何获取AccessToken介绍
这篇文章用.net开发微信如何获取AccessToken介绍
这篇文章用.net开发微信如何获取AccessToken介绍
本文实例为大家分享了获取accesstoken的方法,供大家参考,具体内容如下
AccessToken获取方法
public static Access_token GetAccessToken(){ string formatString = String.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", AppId, AppSecret); Access_token res = new Access_token(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(formatString); request.Method = "GET"; request.ContentType = "text/html;charset=UTF-8"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); string retString = myStreamReader.ReadToEnd(); myStreamReader.Close(); myResponseStream.Close(); if (retString.IndexOf("7200") > 0) { Access_token token = new Access_token(); token = JsonHelper.ParseFromJson<Access_token>(retString); res.access_token = token.access_token; res.expires_in = token.expires_in; } return res;}用.net开发微信如何获取AccessToken介绍由讯客互联微信应用栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“用.net开发微信如何获取AccessToken介绍”