微信公众号借用网页授权代码
编辑时间:2018-01-24 作者:tp论坛 浏览量:2910 来源:tp论坛

tp论坛的。看到的,转过来。

codelayui.code

  1. <?php
  2. /*
  3.  * tom微信借授权
  4.  */
  5. $url = get_url();
  6. $oauth_back_url = urldecode($_GET['oauth_back_url']);
  7. preg_match("#((http|https)://[^?]*/)tom_oauth.php#", $url, $urlmatches);
  8. if (is_array($urlmatches) && ! empty($urlmatches['0'])) {
  9.     $url = str_replace($urlmatches['0'], $oauth_back_url, $url);
  10. }
  11. header('Location: ' . $url);
  12. function get_url()
  13. {
  14.     $protocol = (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
  15.     $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  16.     return $url;
  17. }

如果在你的方法要使用该方法,你只需要在节点中加入以下方法即可

codelayui.code

  1.     if ($wxasnum == 1 || $wxasnum == 10000) {
  2.         $redirecturl = 'xxx.php?oauth_back_url=' . urlencode($redirecturl);
  3.     }


来说两句吧
  • 请先说点什么
    热门评论
    2911人参与,0条评论www