3月更新微信跳轉外部瀏覽器打開指定鏈接源代碼-優雅草bigniu

<code>if(is_weixin()){
\t//這裡的響應頭為關鍵代碼,可根據自己邏輯做修改

\theader("Content-Type: text/plain; charset=utf-8");
header("Accept-Ranges: bytes");
header("Content-Range: bytes 0-1/1");
\theader("Content-Length: 0");
\theader("ETag: W/\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"");
\theader("X-Powered-By: Express");
header("Content-Disposition: attachment; filename=文件名稱.apk");
\techo "這是微信內部瀏覽器,會自動跳轉外部瀏覽器";
}else{
\techo "這是微信外部瀏覽器顯示內容以及業務邏輯";

}
//判斷是否為微信內置瀏覽器
function is_weixin(){

\tif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
\t\treturn true;
\t}

\treturn false;

}
?>
/<code>


另一種方式:

<code>
if(is_weixin()){
\t//這裡的響應頭為關鍵代碼,可根據自己邏輯做修改
\theader("Content-type:appliaction/pdf");
\theader("Content-Disposition:attachment;filename='downloaded.pdf'");
\techo "這是微信內部瀏覽器,會自動跳轉外部瀏覽器";
}else{
\techo "這是微信外部瀏覽器顯示內容以及業務邏輯";


}
//判斷是否為微信內置瀏覽器
function is_weixin(){

\tif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
\t\treturn true;
\t}

\treturn false;

}

/<code>

3月更新微信跳轉外部瀏覽器打開指定鏈接源代碼-優雅草bigniu

以上兩種方式均已失效,請尋找其他跳轉方式,如有發現新方法,會最快更新。感謝支持


分享到:


相關文章: