lushuncheng 4 rokov pred
rodič
commit
20c005090d
2 zmenil súbory, kde vykonal 9 pridanie a 9 odobranie
  1. 1 1
      app/service/WeiboService.php
  2. 8 8
      public/demo.html

+ 1 - 1
app/service/WeiboService.php

@@ -54,7 +54,7 @@ class WeiboService
                 ]
             ];
         }
-        $url = self::$base_url . 'userinfo' . $this->signStr . '&sub=' . $_COOKIE['SUB'] ?? '1235892217';
+        $url = self::$base_url . 'userinfo' . $this->signStr . '&sub=' . $_COOKIE['SUB'];
 
         return self::_httpGet($url);
     }

+ 8 - 8
public/demo.html

@@ -44,7 +44,6 @@
     <input style="display: absolute; z-index: -1; height: 0; width: 0" id="copyTest" />
     <script type="text/javascript">
       var ua = navigator.userAgent.toLocaleUpperCase().indexOf("WEIBO") >= 0;
-      alert(ua);
       function setCookie(cname, cvalue, exdays) {
         var d = new Date();
         d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
@@ -61,24 +60,25 @@
         }
         return "";
       }
+
+      function getQueryString(name) {
+        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+        let r = window.location.search.substr(1).match(reg);
+        if (r != null) return unescape(r[2]);
+        return null;
+      }
       if (!ua) {
         let url = "http://www.weibo.cn/demo.html"; // 要打开的 H5 页面的地址
         let scheme = `sinaweibo://browser?url=` + encodeURIComponent(url);
         window.location.href = `https://m.weibo.cn/feature/openapp?scheme=` + encodeURIComponent(scheme);
       } else {
         if (getCookie("SUB") == "") {
-          setCookie("SUB", " 1235892217", 7);
+          setCookie("SUB", getQueryString("sub"), 7);
           //   alert("未登录");
           //   let url = "http://www.weibo.cn/demo.html"; // 要打开的 H5 页面的地址
           //   //未登录状态下跳转 scheme:
           //   window.location.href = `sinaweibo://login?redirect_scheme` + encodeURIComponent(url);
         }
-        function getQueryString(name) {
-          let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
-          let r = window.location.search.substr(1).match(reg);
-          if (r != null) return unescape(r[2]);
-          return null;
-        }
         $("#login").click(function () {
           getCode("1");
           // callNative('sendCode', '');