浏览器跳转到微信打开链接

简简单单的攻城狮 2017-12-18 11:05:03
已经解决了 ,并且可以长期使用 ,相信大家都看到了, 后台返回来的东西是weixin://dl/business/?ticket=xxx#wechat_redirect;
主要是ticket不好获取
...全文
4088 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_43055658 2018-12-17
  • 打赏
  • 举报
回复
现在很多人都想知道,手机浏览器是怎样唤起微信的又怎么调起内部浏览器的,相信很多同学都做到了调起微信,也调起了微信内置的浏览器。
但是微信总是反馈 跳转失败,这是为什么呢?我之前也是在这一步卡住了很久,后来又在 weixin://dl/business/?ticket=“” 这个 tiket 上面纠结了很久。
最后终于找到了解决方案,已经有平台实现了这个功能http://t.cn/RzKE9ZH
tu_ot 2018-09-21
  • 打赏
  • 举报
回复

include("data/config.php");
$id = $_GET['id'];
$sql = "select * from lists where id='".$id."'";
$rs = mysql_fetch_array(mysql_query($sql));
$s_time = strtotime (date('Y-m-d'));
$e_time = strtotime ($rs['e_time']);
$r_time = ceil(($e_time - $s_time));
if($r_time <= 0){
    echo '这是文本';
    exit;
}
$count = $rs['count'] + 1;
mysql_query($sql = "update wx_list set count='".$count."' where id='".$id."'");
   function get_ticket($code){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        $contents = curl_exec($ch);
        preg_match('/ticket=(.*?)\"/',$contents,$result);
        $content = $result[1];
        return $content;
    }
	
if(time() - $rs['uptime'] >= 1800) {
    $www_url = get_ticket($rs['www_url']);
    mysql_query($sql = "update lists set ticket='".$www_url."',uptime='".time()."' where id='".$id."'");
} else {
    $www_url = $rs['ticket'];
}/*需要数据库文件Q我:3220192183

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>正在跳转中</title>
</head>
<body>
    <div style="text-align: center;font-size: 18px;margin: 100px 0 30px 0;">需要免费代码Q我吧,分享于你,就等你</div>
    <a href="weixin://dl/business/?ticket=<?php echo $www_url ?>" style="width: 90%;background: #1AAD19;text-align: center;color: #fff;margin: 0 auto;box-sizing: border-box;font-size: 18px;line-height: 2.55555556;border-radius: 5px;display: block;text-decoration: none;">再次跳转</a>
    <script>window.location.href="weixin://dl/business/?ticket=<?php echo $www_url ?>";</script>
    <!--要免费代码的Q我吧,分享于你,就等你--> 
</body>
</html>
配置环境,自己搭建下就可以了
tu_ot 2018-09-21
  • 打赏
  • 举报
回复
这里是第二套方案,同样是可以实现的,分享给你们。继续探索更好的技术

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>跳转微信中</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport">
<meta content="telephone=no" name="format-detection">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<?php
// 统一调用微信白名单接口:https://wq.jd.com/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'];
}
?>
<style>
*{ margin:0 auto;}html,body{height:100%;}.container {margin-top: 100px;text-align: center;}.icon {width: 70px;height: 70px;}#ellipsis {display: inline-block;width: 0;}
</style>
</head>
<body>
<div class="container">
<p class="text">正在跳转到微信 <span id="ellipsis">   </span></p></div>
<script type="text/javascript">var ellipsis = ['   ', '.  ', '.. ', '...'];
var index = 0;
var $ellipsis = document.getElementById('ellipsis');
setInterval(function () {
$ellipsis.innerHTML = ellipsis[index++ % 4];
}, 500);</script>
<?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>';
			}
	}
}
?>
<!-- 不懂的地方QQ我:3220192183,免费教学 -->
</body>
</html>
tu_ot 2018-09-21
  • 打赏
  • 举报
回复
这个就跟微信连接wifi是一个道理,用php就可以完成了,早就知道了,都用腻了
  • 打赏
  • 举报
回复
怎么获取ticket
  • 打赏
  • 举报
回复
获取方式加QQ:392072849

61,110

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧