Mindjump!基於微信域名檢測接口的跳轉系統,實現微信跳轉瀏覽器下載app

微信現現在微信對第三方推廣連接的檢測是愈來愈嚴格了,分享連接在微信中轉發常常會被攔截,一旦被攔截用戶在微信中識別二維碼就會提示「已中止訪問該網頁」,這是最近在論壇和貼吧不少用戶諮詢個人問題,其實這個問題不難解決,咱們只要使用微信跳轉API接口便可完美避免以上問題。

因此針對這個問題,特寫此篇文章分享咱們公司以前的處理方案。首先若是咱們沒有專業的技術團隊,咱們能夠去找一家提供該技術的團隊合做,咱們以前一直用的是Mindjump平臺的接口,效果還不錯,很穩定。而後若是你們有本身的技術團隊,是能夠自行編寫跳轉程序的,參考案例見下文。


1、首先咱們說說Mindjump平臺的使用方法:

一、使用瀏覽器打開咱們須要用到的 mindjump 平臺地址:http://www.mindjump.cn/
二、複製連接粘貼進api工具框中,點擊生成跳轉短連接和二維碼
三、複製短鏈接和二維碼前往微信中打開連接或掃碼便可。


2、其次咱們說說如何構建微信跳轉瀏覽器的源碼:

javascript

<style type="text/css">   
    .mask {     
            position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;   
            z-index: 1002; left: 0px;   
            opacity:0.5; -moz-opacity:0.5;   
        }   
</style>
<pre class="html" name="code"><script type="text/javascript">   
    //兼容火狐、IE8 
    //顯示遮罩層  
    function showMask(){   
        $("#mask").css("height",$(document).height());   
        $("#mask").css("width",$(document).width());   
        $("#mask").show();   
    }
    //隱藏遮罩層
    function hideMask(){   
        
        $("#mask").hide();   
    }
   
</script>
<div id="mask" class="mask"></div>  
<a href="javascript:;" onclick="showMask()" >點我顯示遮罩層</a><br />

  
二、Android端微信自動喚醒默認瀏覽器打開網頁連接的代碼php

<?php
// 統一調用微信白名單接口:https://api.mindjump.cn/mjgj/link/GetOpenLink?callback=getOpenLink&rurl=https://dc2.jd.com/auto.php?service=transfer&type=pms&to=(這裏是拼接本身的內容地址好比http://mjbbs.jd.com/data/attachment/forum/201806/08/173526pb2zpjzzooo2ofze.jpg)
if($_GET['t']){
// include("admin/config.php");
// include("admin/function.php");
$code = $_GET['t'];
$info = query ( "jump_logs", "where code='" . $code . "'" );
if($info['code'] == ''){
    echo '跳轉失敗';
    exit(0);
}
if($info['state'] == '1'){
if($info['count'] >= $info['num']){
    echo '跳轉失敗';
    exit(0);
}
$time = strtotime($info['time']);
    if(time() > $time){
        echo '跳轉失敗';
        exit;
    }
}else{
    echo '跳轉失敗';
    exit;
}
if($info['www_url'] == ''){
    echo '請先配置落地頁';
    exit;
}else{
    $w_url_code = $info['rl'];
}
?>
<?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>';
            }
    }
}
?>
<!詳情可參考:http://www.mindjump.cn-->
相關文章
相關標籤/搜索