目前的APP基本都支持二维码扫描下载。由于微信现在是主流的聊天软件,90%的用户都是通过微信分享APP的,再从分享的链接下载apk/ios包。但是微信会自动屏蔽含安装包文件下载的链接,导致用户在微信中打开分享链接提示“已停止访问”,打开了也无法自动下载。由于没有任何提示,故用户并不知道是被屏蔽的,都以为是链接有问题。这就大大地提升了用户流失率,那么在微信中打开下载如何才能自动下载app文件或前往外部浏览器下载呢?下面就为大家介绍下366API的解决方法。
一、首先我们说说366API平台的使用方法:
1、使用浏览器打开我们需要用到的 366API 平台地址:http://www.366api.cn/
2、复制链接粘贴进api工具框中,点击生成跳转短链接和二维码
3、复制短连接和二维码前往微信中打开链接或扫码即可。
二、其次我们说说如何构建微信跳转浏览器的源码:
<?php
// 统一调用微信白名单接口:https://api.366api.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¶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>';
}
}
}
?>
<!详情可参考:http://www.366api.cn-->