網(wǎng)頁(yè)授權(quán)是只能一個(gè)域名,那么問(wèn)題來(lái)了?這怎么搞?

答案就是: 做一個(gè)中轉(zhuǎn)服務(wù)!

域名1:www.test.com

域名2: http://bbs.test.com

這時(shí)候," />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁(yè) > 營(yíng)銷資訊 > 網(wǎng)站運(yùn)營(yíng) > 【微信開(kāi)發(fā)】網(wǎng)頁(yè)授權(quán)多域名解決方案

【微信開(kāi)發(fā)】網(wǎng)頁(yè)授權(quán)多域名解決方案

時(shí)間:2022-08-06 22:00:01 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)

時(shí)間:2022-08-06 22:00:01 來(lái)源:網(wǎng)站運(yùn)營(yíng)

在做微信開(kāi)發(fā)的時(shí)候,會(huì)遇到這樣的場(chǎng)景:一個(gè)公眾號(hào),會(huì)有多個(gè)業(yè)務(wù):官網(wǎng)、論壇、商城等等

網(wǎng)頁(yè)授權(quán)是只能一個(gè)域名,那么問(wèn)題來(lái)了?這怎么搞?

答案就是: 做一個(gè)中轉(zhuǎn)服務(wù)!

域名1:www.test.com

域名2: http://bbs.test.com

這時(shí)候,再解析一個(gè)二級(jí)域名:http://code.test.com 作為中轉(zhuǎn)授權(quán)域名

并在微信公眾平臺(tái)后臺(tái)網(wǎng)頁(yè)授權(quán)域名地方填寫(xiě)這個(gè) 中轉(zhuǎn)域名

www.test.com 授權(quán)代碼改為:

header("location:http://code.test.com/code.php?ask_type=www");http://bbs.test.com 授權(quán)代碼改為:


header("location:http://code.test.com/code.php?ask_type=bbs");http://code.test.com 域名新建三個(gè)文件

code_php 文件代碼:


if(isset($_GET['ask_type']) && !empty($_GET['ask_type'])){ $ask_type = $_GET['ask_type']; if($ask_type == 'bbs'){ $action = "bbs.php"; }elseif($ask_type == 'www'){ $action = "www.php"; } //發(fā)起授權(quán) $appid = ""; $redirect_url = "http://code.test.com/".$action; $code_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".urlencode($redirect_url)."&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; header("location: ".$code_url); die;}else{ echo "nononono";}bbs.php文件代碼:


if(isset($_GET['code']) && !empty($_GET['code'])){ $code = $_GET['code']; $bbs = "http://bbs.test.com/"; header("location:".$bbs."?code=".$code);}else{ echo 'nonono';} www.php文件代碼:


if(isset($_GET['code']) && !empty($_GET['code'])){ $code = $_GET['code']; $bbs = "http://www.test.com/"; header("location:".$bbs."?code=".$code);}else{ echo 'nonono';}目前是兩個(gè)業(yè)務(wù)域名。如果還有其他業(yè)務(wù),可以按照上述例子新增!

關(guān)鍵詞:解決,方案,授權(quán)

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉