<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      公眾號jssdk使用代碼

      使用jssdk的時候,發生了在配置時候產生的問題。config:invalid signature

      后來發現是因為地址配置錯誤產生的。

      如果代碼寫完后,確認簽名算法正確,可用http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign 頁面工具進行校驗。

       

      參考網址:

      1. http://www.rzrgm.cn/vipstone/p/6732660.html
      2. https://blog.csdn.net/dmw412724/article/details/81083058

       

      我遇到的問題是

      1. 在生成簽名(signature)的時候,生成出錯了。是我的 window.location.href.split('#')[0]  手寫的,應該動態獲取。(建議全部小寫)
      2. 在簽名成功以后,傻傻的調用  wx.ready(function () {  })   一直沒有執行。在這里也花費了好久時間

       

      @{
          Layout = null;
      }
      
      <!DOCTYPE html>
      
      <html>
      <head>
          <meta name="viewport" content="width=device-width" />
          <script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js" type="text/javascript"></script>
          <script src="~/scripts/jquery/jquery-3.3.1/jquery-3.3.1.min.js"></script>
          <title>簽到/簽退</title>
          <script type="text/javascript">
      
              jQuery.post("/wxser/GetJSSDKConfig", {
                  "url": encodeURIComponent(window.location.href.split('#')[0]),
                  "t": new Date().getTime()
              }, function (result) {
      
                  wx.config({
                      debug: false, // 開啟調試模式,調用的所有api的返回值會在客戶端alert出來,若要查看傳入的參數,可以在pc端打開,參數信息會通過log打出,僅在pc端時才會打印。
                      appId: result.appId, // 必填,公眾號的唯一標識
                      timestamp: result.timestamp, // 必填,生成簽名的時間戳
                      nonceStr: result.nonceStr, // 必填,生成簽名的隨機串
                      signature: result.signature,// 必填,簽名,見附錄1
                      jsApiList: ['openLocation', 'getLocation'] // 必填,需要使用的JS接口列表,所有JS接口列表見附錄2
                  });
      
                  setTimeout(photo, 2000);
              });
      
      
              function photo() {
                  wx.getLocation({
                      type: 'gcj02', // 默認為wgs84的gps坐標,如果要返回直接給openLocation用的火星坐標,可傳入'gcj02'
                      success: function (res) {
                          var latitude = res.latitude; // 緯度,浮點數,范圍為90 ~ -90
                          var longitude = res.longitude; // 經度,浮點數,范圍為180 ~ -180。
                          var speed = res.speed; // 速度,以米/每秒計
                          var accuracy = res.accuracy; // 位置精度
                          if (latitude && longitude) {
                              $.ajax({
                                  url: "/wxser/ClockInForAttendanceDo",
                                  data: {
                                      code: '@(Request.QueryString["code"])',
                                      state: '@(Request.QueryString["state"])',
                                      gps: longitude + ',' + latitude
                                  },
                                  success: function (res) {
                                      document.write("<h2>" + res + "</h2>");
                                  }
                              });
                          }
                      }
                  });
              }
      
          </script>
          <style>
              .btn0 {
                  width: 80%;
                  margin-top: 10px;
                  height: 20px;
                  background-color: burlywood;
                  color: white;
                  border-radius: 98px;
                  display: none;
              }
          </style>
      </head>
      <body>
          <h2>正在簽@(Request.QueryString["state"] == "1" ? "" : "退")...</h2>
          <div style="text-align:center;width:100%">
              <input type="button" value="打卡" id="gps" onclick="photo()" class="btn0" />
          </div>
      </body>
      </html>

       

      [HttpPost]
      public JsonResult GetJSSDKConfig(string url)
      {
          Log.Debug("GetJSSDKConfig【url】:", Server.UrlDecode(url));
          string jsapi_ticket = WXSmartNote.Getjsapi_ticket();
          string timestamp = WXSmartNote.GetTimeStamp(), nonceStr = "scmone";   //timestamp 時間戳,nonceStr 加密碼
          string str1 = string.Format(@"jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}"
                                      , jsapi_ticket, nonceStr, timestamp, Server.UrlDecode(url));
          //獲取簽名
          string signature = WXSmartNote.GetSHA1(str1);
          Log.Debug("GetJSSDKConfig【signature】:", signature);
          ViewBag.appId = WxSmartNoteConfig.APPID;
          ViewBag.signature = signature;
          ViewBag.timestamp = timestamp;
          ViewBag.nonceStr = nonceStr;
          return this.Json(new
          {
              appId = WxSmartNoteConfig.APPID,
              signature = signature,
              timestamp = timestamp,
              nonceStr = nonceStr
          });
      }
      
      
      
      
         public static string GetTimeStamp()
      {
          TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
          return Convert.ToInt64(ts.TotalSeconds).ToString();
      }
      
      
        public static string GetSHA1(string rawData)
      {
          Log.Debug("簽名源數據:", rawData);
          //創建SHA1簽名類
      
          SHA1 sha1 = new SHA1CryptoServiceProvider();
      
          //編碼用于SHA1驗證的源數據
      
          byte[] source = Encoding.UTF8.GetBytes(rawData);
      
          //生成簽名
      
          byte[] target = sha1.ComputeHash(source);
      
          //轉化為string類型,注意此處轉化后是中間帶短橫杠的大寫字母,需要剔除橫杠轉小寫字母
      
          string result = BitConverter.ToString(target).Replace("-", "").ToLower();
      
          //輸出驗證結果
      
          return result;
      
      }
      
      
      public static string Getjsapi_ticket()
      {
          RedisHelper redis = new RedisHelper();
          string key_access = "access_token";
          string key_ticket = "ticket";
          string ticket = redis.StringGet(key_ticket);
          if (!string.IsNullOrEmpty(ticket))
          {
              return ticket;
          }
          else
          {
              string access_token = redis.StringGet(key_access);
              if (string.IsNullOrEmpty(access_token))
              {
                  access_token = GetAccess_Token();
                  redis.StringSet(key_access, access_token, TimeSpan.FromSeconds(7100));
              }
              if (string.IsNullOrEmpty(access_token)) return "";
      
              string url = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", access_token);
      
              var data = GetPage(url);
              Log.Debug("獲取用戶Access_Token GetAccess_Token", data);
              Dictionary<string, object> obj = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
      
              object result = "";
              if (!obj.TryGetValue("ticket", out result))
                  return "";
              ticket = result.ToString();
              redis.StringSet(key_ticket, ticket, TimeSpan.FromSeconds(7100));
      
              return ticket;
          }
      }

       

      posted @ 2019-11-28 16:28  Vincent_void  閱讀(613)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 亚洲V天堂V手机在线| 97超级碰碰碰久久久久| 欧美日韩在线亚洲二区综二| 六月丁香婷婷色狠狠久久| caoporn成人免费公开| 国产成人精品免费视频app软件| 日本中文字幕有码在线视频 | 99国产精品欧美一区二区三区| 高中女无套中出17p| 午夜福利一区二区三区在线观看| 一区二区三区精品偷拍| 一区二区三区四区亚洲综合| 色色97| 国产AV影片麻豆精品传媒| 蜜臀av一区二区三区不卡| 99久久国产露脸国语对白| 国产老熟女一区二区三区| 97夜夜澡人人爽人人模人人喊| 达日县| 国产综合久久久久久鬼色| 无遮无挡爽爽免费视频| 亚洲欧美中文字幕日韩一区二区| 中文字幕人妻av第一区| 男人下部进女人下部视频| 蜜臀av日韩精品一区二区| AV在线亚洲欧洲日产一区二区| 辛集市| 亚洲av成人久久18禁| 色综合久久中文综合网| 精品国产女同疯狂摩擦2| 国产福利酱国产一区二区| 国产欧美一区二区精品性色| 韩国无码AV片午夜福利| 国产一区二区三区免费观看| 四虎永久免费精品视频| 高清自拍亚洲精品二区| 免费无遮挡无码永久视频| 亚洲AV无码一二区三区在线播放| 影音先锋大黄瓜视频| 内射无套内射国产精品视频| 亚洲成A人片在线观看的电影|