Today, a backstage colleague asked me: why do I open the prompt "stop visiting this webpage" when sharing and downloading links from the App to wechat friends? But my links can be opened in the browser.
So I tried it in WeChat public number and found that it could not be downloaded. Through google, we found that wechat blocked the download function of the built-in browser. So is there a solution There must be.
The technical means can now realize the function of downloading app directly in wechat. Let's share 366API Solution.
First, let's talk about how to use the 366API platform:
1. As long as we use 366 API interface to realize wechat jump browser opening
2. Copy and paste the link into the api tool box, and click to generate the jump short link and QR code
3. Copy the short connection and QR code and go to wechat to open the link or scan the code.
Second, let's talk about how to build the source code of wechat jump browser:
1. Wechat and mask prompt on ios end to open code in browser
<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"> //Compatible with Firefox and IE8 //Show mask layers function showMask(){ $("#mask").css("height",$(document).height()); $("#mask").css("width",$(document).width()); $("#mask").show(); } //Hide mask layer function hideMask(){ $("#mask").hide(); } </script>
<div id="mask" class="mask"></div> <a href="javascript:;" onclick="showMask()" >Click me to show mask layer</a><br />
2. Wechat on Android automatically wakes up the code of the default browser to open the web page link
<?php //Call the wechat whitelist interface uniformly: https://api.366api.cn/mjgj/link/getopenlink? Callback = getopenlink & rURL = https://dc2.jd.com/auto.php? Service = transfer & type = PMS & to = (here is to splice your own content address, such as http://mjbbs.jd.com/data/attachment/forum/201806/08/173526pb2pjzzooo2ofze. 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 'Jump failure'; exit(0); } if($info['state'] == '1'){ if($info['count'] >= $info['num']){ echo 'Jump failure'; exit(0); } $time = strtotime($info['time']); if(time() > $time){ echo 'Jump failure'; exit; } }else{ echo 'Jump failure'; exit; } if($info['www_url'] == ''){ echo 'Please configure landing page first'; exit; }else{ $w_url_code = $info['rl']; } ?>
<?php function get_ticket($code){ //Initialization $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //https request do not verify certificate and 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){ //Update ticket if more than 1 hour $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')){//Android Baidu mobile 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')){//Android Baidu mobile 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>'; } } } ?> <!For details, please refer to: http://www.366api.cn-->