麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > .NET > 正文

微信公眾平臺(tái)開發(fā)之獲得ACCESSTOKEN .Net代碼解析

2024-07-10 13:30:49
字體:
供稿:網(wǎng)友

如何認(rèn)證成為開發(fā)者?請(qǐng)點(diǎn)擊第一篇文章進(jìn)行查看,成為了開發(fā)者之后微信平臺(tái)會(huì)給您appid和secret,在訂閱號(hào)中是沒有的,所以因該申請(qǐng)一下服務(wù)號(hào),有了ACCESSTOKEN才能做添加菜單,上傳/下載圖片等功能。

private string GetToken()   {     // 也可以這樣寫:     //return GetPage("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的appid&secret=你的secret", "");         string res = "";     HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的appid&secret=你的secret"); 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();         List<ACCESSTOKEN> myACCESSTOKEN = Json.JSONStringToList<ACCESSTOKEN>(content);       res = myACCESSTOKEN[0].access_token;      }     return res;   }   public string GetPage(string posturl, string postData)   {     Stream outstream = null;     Stream instream = null;     StreamReader sr = null;     HttpWebResponse response = null;     HttpWebRequest request = null;     Encoding encoding = Encoding.UTF8;     byte[] data = encoding.GetBytes(postData);     // 準(zhǔn)備請(qǐng)求...     try     {       // 設(shè)置參數(shù)       request = WebRequest.Create(posturl) as HttpWebRequest;       CookieContainer cookieContainer = new CookieContainer();       request.CookieContainer = cookieContainer;       request.AllowAutoRedirect = true;       request.Method = "POST";       request.ContentType = "application/x-www-form-urlencoded";       request.ContentLength = data.Length;       outstream = request.GetRequestStream();       outstream.Write(data, 0, data.Length);       outstream.Close();       //發(fā)送請(qǐng)求并獲取相應(yīng)回應(yīng)數(shù)據(jù)       response = request.GetResponse() as HttpWebResponse;       //直到request.GetResponse()程序才開始向目標(biāo)網(wǎng)頁發(fā)送Post請(qǐng)求       instream = response.GetResponseStream();       sr = new StreamReader(instream, encoding);       //返回結(jié)果網(wǎng)頁(html)代碼       string content = sr.ReadToEnd();       string err = string.Empty;       return content;     }     catch (Exception ex)     {       string err = ex.Message;       Response.Write(err);       return string.Empty;     }   }

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到ASP.NET教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 原来神马影院手机版免费 | 成人毛片视频在线观看 | 欧美激情综合网 | 久久99精品久久久久久青青日本 | 92看片淫黄大片欧美看国产片 | 羞羞漫画无遮挡观看 | 久久综合精品视频 | 欧美性生活视频免费看 | 干一夜综合 | 综合网天天色 | 久草导航 | 最新福利在线 | 亚洲欧美国产高清 | 免费观看又色又爽又黄的崩锅 | 日韩黄a | 成人在线高清视频 | 成年人黄色免费网站 | 欧美人禽| 九一免费版在线观看 | 91香蕉国产亚洲一区二区三区 | 久久精品欧美电影 | 在线看免费观看日本 | 成人在线免费观看网址 | 日韩视频1 | 欧美日本色| 久久精品亚洲欧美日韩精品中文字幕 | 无码专区aaaaaa免费视频 | 成人性视频在线 | 成年免费网站 | 91嫩草丨国产丨精品入口 | av电影免费观看 | 国产精品一区免费在线观看 | 爽毛片| 亚洲视频成人在线 | 国产日韩a| 黄色二区三区 | 美国人成人在线视频 | 一级大片久久 | 91羞羞| 全黄裸片武则天一级第4季 九色p | 久久精品一区二区三区不卡牛牛 |