很多朋友的网页推广链接需要在微信中进行的宣传、传播、下载等等,但是各位朋友一定发现了微信会经常屏蔽掉这些网页链接的。此时用户点开则报红并提示“已停止访问该网页” 。那我们要怎么解决这个问题呢?
解决方案:
我们基于微信接口开发了一款全新的手机端微信中打开网页的程序,通过这个程序生成的链接,安卓用户在微信中点击的话,是可以直接跳转手机默认浏览器打开网页链接的。IOS用户在微信中点击的话会弹出一个遮罩提示用户用浏览器打开网页链接。这样的话大大的减少了用户的操作步骤,使用我们的方法都不会出现微信所谓的捆绑下载。给以用户以良好的下载体验,对我们的推广转化率会有显著的提升。
一段源码可供大家参考:
<?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-->
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69926607/viewspace-2646412/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/69926607/viewspace-2646412/

647

被折叠的 条评论
为什么被折叠?



