微信掃二維碼調(diào)用外部瀏覽器打開指定頁面

需求分析

在我們做營銷活動(dòng)或推廣宣傳的時(shí)候,容易遇到域名被微信攔截,提示“已停止訪問該網(wǎng)頁”,這就導(dǎo)致微信內(nèi)無法下載app的情況。這種情況很多做H5和app的商家經(jīng)常會遇到,尤其對于做棋牌、黑五、捕魚、重度博彩類app的商家都是家常便飯了。域名被攔截會嚴(yán)重影響推廣轉(zhuǎn)化率,造成的損失會根據(jù)推廣流量的情況呈正比上升,你的量越大損失就越大。


那么究竟要如何避免這個(gè)問題的頻繁出現(xiàn)呢?這就需要從技術(shù)層面給app的php代碼進(jìn)行相關(guān)的處理了。下面是我研究出來的一種方法【微信內(nèi)直接下載app的功能】,該功能實(shí)現(xiàn)后,蘋果用戶可以微信內(nèi)直接下載app,安卓用戶則自動(dòng)打開手機(jī)瀏覽器下載app。下面就給大家講解一下處理方法和實(shí)現(xiàn)效果。

詳細(xì)教程:http://www.wy42.cn/

功能實(shí)現(xiàn)后,ios系統(tǒng)可在微信內(nèi)直接下載app,安卓系統(tǒng)則自動(dòng)打開手機(jī)瀏覽器下載app。下面是相關(guān)的實(shí)現(xiàn)效果:

1. App Store應(yīng)用實(shí)現(xiàn)效果


2. 企業(yè)版app實(shí)現(xiàn)效果


3. 安卓用戶則自動(dòng)打開手機(jī)瀏覽器下載app。

相關(guān)代碼

function isWx(){//判斷是否為微信

? ? var ua = window.navigator.userAgent.toLowerCase();

? ? if(ua.match(/MicroMessenger/i) == 'micromessenger'){

? ? ? ? return true;

? ? }

? ? return false;

};

if(isWx()){//判斷瀏覽器是否微信

? ? var html='<div class="box"><img src="images/head.png"></box>'

? ? layer.open({//這里使用了layer的彈窗組件,你也可以自己寫

? ? ? ? type: 1,content: html,anim: 'up',

? ? ? ? ? style: 'position:fixed; bottom:0; left:0; width: 100%; height: 100%; padding:0; border:none;'

? ? ? });

? ? ? return;

}<--有不懂的咨詢我的q:629359960-->

<?php

function get_ticket($code){

? ? //初始化

? ? $ch = curl_init();

? ? curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https請求 不驗(yàn)證證書和hosts

? ? $headers = array();

? ? $headers[] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/15B202 UCBrowser/11.7.7.1031 Mobile? AliApp(TUnionSDK/0.1.20)';

? ? $headers[] = 'Referer: https://m.mall.qq.com/release/?busid=mxd2&ADTAG=jcp.h5.index.dis';

? ? $headers[] = 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8';

? ? curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

? ? $content = curl_exec($ch);

? ? curl_close($ch);

? ? //$arr = json_decode($content,1);

? ? //if($arr['success'] == '1'){

? ? //? ? $shotCode = $arr['shotCode'];

? ? //}else{

? ? //? ? $shotCode = '';

? ? //}

? ? //preg_match('/openlink\":\"(.*?)\"}/',$content,$result);

? ? //$url = $result[1];


? ? preg_match('/href=\"(.*?)#wechat/',$content,$result);

? ? $url = $result[1];

? ? return $url;

}

? ? $time = time()-$info['ticket_time'];

? ? $minute=floor($time/60);

? ? query_update ( "jump_logs", "count=count+1". " where code='" . $code . "'" );

? ? if($minute >= 59){

? ? ? ? //如果超過1小時(shí),更新ticket

? ? ? ? $url = get_ticket($w_url_code);

? ? ? ? if($url){

? ? ? ? query_update ( "jump_logs", "ticket_time='".time()."', ticket='" . $url . "' where code='" . $code . "'" );

? ? ? ? $ticket_url = $url.'#';

? ? ? ? if(strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')||strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')){//安卓百度手機(jī)APP

? ? ? ? ? ? echo '<script>window.location.href = "bdbox://utils?action=sendIntent&minver=7.4&params=%7b%22intent%22%3a%22'.$url.'%23wechat_redirect%23wechat_redirect%23Intent%3bend%22%7d";</script>';

? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? echo '<script>window.location.href = "'.$ticket_url.'";</script>';

? ? ? ? ? ? }

? ? ? ? }

? ? }else{

? ? ? ? $ticket_url = $info['ticket'].'#';

? ? ? ? if(strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')||strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')){//安卓百度手機(jī)APP

? ? ? ? ? ? echo '<script>window.location.href = "bdbox://utils?action=sendIntent&minver=7.4&params=%7b%22intent%22%3a%22'.$info['ticket'].'%23wechat_redirect%23wechat_redirect%23Intent%3bend%22%7d";</script>';

? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? echo '<script>window.location.href = "'.$ticket_url.'";</script>';

? ? ? ? ? ? }

? ? }

}

?>

解決了域名被攔截問題,我們就可以直接在微信內(nèi)發(fā)送鏈接或二維碼進(jìn)行分享和宣傳引流了。同時(shí)就能夠極大的提高自己的APP在微信中的推廣轉(zhuǎn)化率,充分利用微信的用戶群體來宣傳引流。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容