问题分析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¶ms=%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¶ms=%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在微信中的推广转化率,充分利用微信的用户群体来宣传引流。