欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

asp.net微信開發(fā)之開發(fā)者接入技巧有哪些-創(chuàng)新互聯(lián)

這篇文章主要介紹asp.net微信開發(fā)之開發(fā)者接入技巧有哪些,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

創(chuàng)新互聯(lián)建站客戶idc服務(wù)中心,提供服務(wù)器托管、成都服務(wù)器、成都主機托管、成都雙線服務(wù)器等業(yè)務(wù)的一站式服務(wù)。通過各地的服務(wù)中心,我們向成都用戶提供優(yōu)質(zhì)廉價的產(chǎn)品以及開放、透明、穩(wěn)定、高性價比的服務(wù),資深網(wǎng)絡(luò)工程師在機房提供7*24小時標準級技術(shù)保障。

先上圖,看一看需要進行哪些項目的操作:

asp.net微信開發(fā)之開發(fā)者接入技巧有哪些

在項目的根目錄或者特定的文件夾內(nèi),創(chuàng)建一個ashx文件(一般處理程序文件),如圖


 public void ProcessRequest(HttpContext context)
 {
  context.Response.ContentType = "text/plain";
  
  string postString = string.Empty;
  if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
  {
  using (Stream stream = HttpContext.Current.Request.InputStream)
  {
   Byte[] postBytes = new Byte[stream.Length];
   stream.Read(postBytes, 0, (Int32)stream.Length);
   postString = Encoding.UTF8.GetString(postBytes);
  }

  if (!string.IsNullOrEmpty(postString))
  {
   ResponseXML(postString);//返回給微信用戶信息
  }

  ///加載自定義菜單
  string postData = "{" + "\r\n";
  postData += "\"button\":[ " + "\r\n";
  postData += "{ " + "\r\n";
  postData += "\"name\":\"簡單查\"," + "\r\n";
  postData += "\"sub_button\":[" + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"我的薪資\", " + "\r\n";
  postData += " \"key\":\"mypay\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"天氣預(yù)報\", " + "\r\n";
  postData += " \"key\":\"tianqiyubao\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"view\"," + "\r\n";
  postData += " \"name\":\"火車票查詢\", " + "\r\n";
  postData += " \"url\":\"http://www.deqiaohr.com.cn/*******.aspx\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"開心一刻\", " + "\r\n";
  postData += " \"key\":\"kaixinyixiao\"" + "\r\n";
  postData += " }]" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{" + "\r\n";
  postData += "\"name\":\"會員管理\", " + "\r\n";
  postData += "\"sub_button\":[" + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"view\"," + "\r\n";
  postData += " \"name\":\"會員注冊\", " + "\r\n";
  postData += " \"url\":\"http://www.deqiaohr.com.cn/****.aspx\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"view\"," + "\r\n";
  postData += " \"name\":\"重置密碼\", " + "\r\n";
  postData += " \"url\":\"http://www.deqiaohr.com.cn/****.aspx\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"修改資料\", " + "\r\n";
  postData += " \"key\":\"updateMessage\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"我的提問\", " + "\r\n";
  postData += " \"key\":\"mywen\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"聯(lián)系客服\", " + "\r\n";
  postData += " \"key\":\"PhoneSerices\"" + "\r\n";
  postData += " }]" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{" + "\r\n";
  postData += "\"name\":\"活動通知\"," + "\r\n";
  postData += "\"sub_button\":[" + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"近期活動\", " + "\r\n";
  postData += " \"key\":\"yuangonghuodong\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"近期通知\", " + "\r\n";
  postData += " \"key\":\"yuangongtongzhi\"" + "\r\n";
  postData += "}," + "\r\n";
  postData += "{ " + "\r\n";
  postData += " \"type\":\"click\"," + "\r\n";
  postData += " \"name\":\"有問必答\", " + "\r\n";
  postData += " \"key\":\"youwenbida\"" + "\r\n";
  postData += " }]" + "\r\n";
  postData += "}]" + "\r\n";
  postData += "}" + "\r\n";

  //自定義菜單token的獲取 是用 下面的兩個參數(shù) 獲取的 不能直接用 公眾平臺的token
  string to = GetAccessToken();
  //本人不喜歡 后臺 json的操作 直接截取就可以了 得到的就是 token 或者 自己 獲取 json的token
  to = to.Substring(17, to.Length - 37);
  //加載菜單
  string i = GetPage("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + to, postData);

  }
  else
  {
  Auth(); //微信接入的測試
  }
  
 }

 

 /// <summary>
 /// 獲取通行證
 /// </summary>
 /// <returns></returns>
 private string GetAccessToken()
 {
  string url_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=********&secret=*********";
  HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url_token);
  myRequest.Method = "GET";
  HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
  StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
  string content = reader.ReadToEnd();
  reader.Close();
  return content;
 }

 

 /// <summary>
 /// 加載菜單項
 /// </summary>
 /// <param name="p"></param>
 /// <param name="postData"></param>
 /// <returns></returns>
 private string GetPage(string p, 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);
  // 準備請求...
  try
  {
  // 設(shè)置參數(shù)
  request = WebRequest.Create(p) 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ā)送請求并獲取相應(yīng)回應(yīng)數(shù)據(jù)
  response = request.GetResponse() as HttpWebResponse;
  //直到request.GetResponse()程序才開始向目標網(wǎng)頁發(fā)送Post請求
  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;
  return string.Empty;
  }
 }

 

 /// <summary>
 /// 獲取參數(shù)進行認證
 /// </summary>
 private void Auth()
 {
  string token = "*****";//你申請的時候填寫的Token

  string echoString = HttpContext.Current.Request.QueryString["echoStr"];
  string signature = HttpContext.Current.Request.QueryString["signature"];
  string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
  string nonce = HttpContext.Current.Request.QueryString["nonce"];

  if (CheckSignature(token, signature, timestamp, nonce))
  {
  if (!string.IsNullOrEmpty(echoString))
  {
   HttpContext.Current.Response.Write(echoString);
   HttpContext.Current.Response.End();
  }
  }

 }
 /// <summary>
 /// 對微信傳入?yún)?shù)進行封裝到數(shù)組,拼接字符串,進行加密操作
 /// </summary>
 /// <param name="token"></param>
 /// <param name="signature"></param>
 /// <param name="timestamp"></param>
 /// <param name="nonce"></param>
 /// <returns></returns>
 private bool CheckSignature(string token, string signature, string timestamp, string nonce)
 {
  string[] ArrTmp = { token, timestamp, nonce };//將參數(shù)放進數(shù)組

  Array.Sort(ArrTmp);//對數(shù)組進行排序
  string tmpStr = string.Join("", ArrTmp);//將數(shù)組進行拼接
  ///對拼接后的字符串進行加密操作
  tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
  //轉(zhuǎn)換成小寫形式
  tmpStr = tmpStr.ToLower();
  //比對成功返回
  if (tmpStr == signature)
  {
  return true;
  }
  else
  {
  return false;
  }
 }

以上是“asp.net微信開發(fā)之開發(fā)者接入技巧有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

標題名稱:asp.net微信開發(fā)之開發(fā)者接入技巧有哪些-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://aaarwkj.com/article20/dpisco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計網(wǎng)站制作、網(wǎng)站設(shè)計公司靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
久久综合婷婷亚洲色图| 99国产精品欧美一区二区| av人妻熟女少妇蒂亚| 国产产品在线免费看91| 亚洲av色国产精品色午含羞草| 欧美艳星一区二区三区四区 | 青青草原网址在线观看| 日韩三级视频一区二区| 精品人妻系列一区二区| 快播av手机在线播放| 日本一区二区三级在线观看| 国产亚洲成人精品一区| 福利1中文字幕手机在线| 国产剧情av专业在线观看| 亚洲av乱码一区二区三| 日韩久久精品免费视频| 丰满人妻在线一区二区三区| 亚洲国产丁香综合激情啪| 国产伦精品二区三区视频| 一区二区三区午夜激情| 黄色三级视频一区二区三区| 欧美一区二区日韩国产| 久久精品久久久精品| 久久精品资源综合网| 国产综合一区二区三区视频| 国产成人亚洲综合色影视| 中文精品字幕人妻熟女小妇| 亚洲区一区二区三区精品| 亚洲乱码一区二区在线| 免费爱爱视频在线观看| 久久综合婷婷亚洲五月| 偷拍大神女厕偷拍作品| 精品国产一区av在线| 国产综合亚洲欧美日韩| av天堂最新资源在线| 日本人妻成人免费大片| 天天做日日干夜夜操| 国产婷婷综合一区二区| 久久精品国产亚洲av麻豆尤物| 久久精品一区二区东京热| 日本国产一区二区三区在线|