微信中点击连接直接跳到默认浏览器是怎么实现的?(不是在微信内置浏览器打开)

商业分析在微信的使用人数已经高居各通信APP的榜首的同时,微信成为了我国移动流量最大的平台之一。在次趋势的引导下,不少的商家、体户便抓住了这一机遇,利用微信这个渠道来作产品的推广、以及营销方案宣传。可是好景不长,微信从去年开始就对这一块管制的很严,在微信内分享连接很容易就会被微信拦截屏蔽。要是微信用户收到被屏蔽的连接后,打开提示“ 该连接已中止访问 ”时会致使用户量的大量流失。php

不少商家爱对此表示脑壳大,想解决但又不知道该如何解决。其实这个问题不难解决,只要在产品的php代码中进行相关的处理,并加上跳转接口,即能预防域名被拦截的同时,也能让用户直接在微信内打开或自动跳转手机默认浏览器打开。html

技术来源android

一、http://www.mindjump.cnios

 

二、http://www.366api.cnweb

 

方案一json

实现微信跳转连接,也就是微信内置浏览器自动跳转其余浏览器打开连接。(该方案适合推广APP及其余H5页面)小程序

功能实现后, 苹果用户便可在微信内直接下载app也能够跳转浏览器下载,安卓用户则自动打开手机浏览器下载app, 若是不含下载文件,则直接从微信内跳转到手机浏览器访问指定页面 。下面是含app下载文件的实现效果:api

1. 苹果跳转浏览器效果浏览器

2. App Store应用实现效果微信

3. 企业版app实现效果

4. 安卓用户则自动打开手机默认浏览器访问指定h5页面或者下载app。

 

方案二

对域名所属的JS代码进行处理,实现微信防封域名。(该方案适合推广H5小程序)

用以上两种方式皆能够避免分享连接在微信内被拦截,功能实现后用户在微信内打开分享连接就能够正常访问了。

如此一来咱们就解决了域名被微信拦截而没法打开的问题了,那么接下来就能够在微信内大量的分享连接或二维码来进行宣传引流。不只提升了用户体验,也可以极大地提升本身的APP在微信中的推广转化率,充分利用微信的用户群体来达到咱们的指望。    

代码解析

html代码

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-->

JS代码

<?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>'; } } } ?> <!--有不懂的地方联系个人Q:511979480--> 

 

CSS代码

function isDevice(){//判断是android仍是ios仍是web var ua = navigator.userAgent.toLowerCase(); if(ua.match(/iPhone\sOS/i) == "iphone os" || ua.match(/iPad/i)=="ipad"){//ios return "iOS"; } if(ua.match(/Android/i) == "android") { return "Android"; } return "Web"; };
header("Content-type:application/pdf"); header("Content-Disposition:attachment;filename='downloaded.pdf'"); 
相关文章
相关标签/搜索