微信直接喚起手機默認瀏覽器的調研方案

 問題分析php

當咱們在微信內分享連接或二維碼的時候,咱們會發現咱們的網站是能夠在瀏覽器里正常打開的,但就是不能在微信裏打開,提示 「 已中止訪問該網頁 」,不管是聊天框也同樣。說是系統檢測的您的網址被微信策略屏蔽,有任何問題請到微信攔截頁面上申訴處理。html

其實這個問題不少使用微信推廣的商家幾乎天天都能遇到,這是一個使人很是頭疼的問題。由於它不只影響了推廣效率,還給用戶帶來了很是差的體驗,變向地天然就是會影響到咱們的收益。ios

解決方案json

就以上所說的問題,其實說難解決也不難,說簡單也不簡單,一塊兒都依據在你到底對微信的系統研究有多深。我給你們講一下個人經驗吧,其實我碰到這個問題我都是直接在php代碼里加一點料,再加個跳轉接口,就完美地解決了該痛點。瀏覽器

下面給你們簡單講解一下究竟如何實現改功能吧。微信

詳細實現步驟:http://sk.go51w.cn/nt0052.htmlapp

處理方案curl

一、微信內直接打開連接下載app網站

二、微信內自動跳到手機瀏覽器打開網頁url

實現效果

首先咱們須要對分享域名加JS防封接口,而後咱們再加入瀏覽器外跳接口,以達到咱們的指望需求。

功能實現後,ios系統可在微信內直接下載app,安卓系統則自動打開手機瀏覽器下載app,若是不含下載文件,則直接打開網頁。下面是含app下載的實現相關的實現效果:

 

2. 企業版app實現效果

 

3. 安卓用戶則自動打開手機瀏覽器打開指定連接或者下載app。

 

相關代碼

​
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:511979480-->

 

<?php
function get_ticket($code){
    //初始化
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https請求 不驗證證書和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小時,更新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')){//安卓百度手機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')){//安卓百度手機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>';
            }
    }
}
?>
var is_weixin = (function(){return navigator.userAgent.toLowerCase().indexOf(‘micromessenger’) !== -1})();
window.onload = function() {
var winHeight = typeof window.innerHeight != ‘undefined’ ? window.innerHeight : document.documentElement.clientHeight; //兼容IOS,不須要的能夠去掉
var btn = document.getElementById(‘J_weixin’);
var tip = document.getElementById(‘weixin-tip’);
var close = document.getElementById(‘close’);
if (is_weixin) {
btn.onclick = function(e) {
tip.style.height = winHeight + ‘px’; //兼容IOS彈窗整屏
tip.style.display = ‘block’;
return false;
}
close.onclick = function() {
tip.style.display = ‘none’;
}
}
}

 

功能實現後就能夠解決微信內沒法下載app的難題了,完成以上步驟還能夠最大程度防止下載連接被微信攔截。這樣咱們就能夠直接用微信掃描二維碼在微信中分享和宣傳引流了。如此咱們即可以極大的提升本身的APP在微信中的推廣轉化率,充分利用微信的用戶羣體來宣傳引流。

相關文章
相關標籤/搜索