tp论坛的。看到的,转过来。
<?php
/*
* tom微信借授权
*/
$url = get_url();
$oauth_back_url = urldecode($_GET['oauth_back_url']);
preg_match("#((http|https)://[^?]*/)tom_oauth.php#", $url, $urlmatches);
if (is_array($urlmatches) && ! empty($urlmatches['0'])) {
$url = str_replace($urlmatches['0'], $oauth_back_url, $url);
}
header('Location: ' . $url);
function get_url()
{
$protocol = (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
return $url;
}如果在你的方法要使用该方法,你只需要在节点中加入以下方法即可
if ($wxasnum == 1 || $wxasnum == 10000) {
$redirecturl = 'xxx.php?oauth_back_url=' . urlencode($redirecturl);
}