点击外部浏览器的按钮跳转到微信app打开网站任意url

跟大家交流技术
使用weixin://可以直接唤起微信,现在很多老铁们都希望还要在微信中打开自己的网站,没有什么功能是我们程序猿做不出来的,我自己也做了一套这样的功能,你们看看我写的代码怎样,我本人是用php+mysql写的,搭配数据库环境就可以了。
php

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 lists 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'];
}
  •  

前端html

<!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;">免费代码联系我QQ:3220192183</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>
    <!--不会配置环境的联系我QQ:3220192183--> 
</body>
</html>
  •  

最终我能实现的效果,看能不能帮到你,我只想和大家一起分享自己的技术成果

点击外部浏览器的按钮跳转到微信app打开网站任意url
点击外部浏览器的按钮跳转到微信app打开网站任意url


实现这种功能有很多种办法,知道一种怎么实现了,那么一理通,百里通的。现在就先消化上面的内容吧,后面我再发第二种方法,大家一步一步,更上一层楼。

-官方vip.wxticket.com-点击外部浏览器的按钮跳转到微信app打开网站任意url