點選外部瀏覽器的按鈕跳轉到微信開啟網站url
阿新 • • 發佈:2018-12-11
跟大家交流技術 使用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 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 wx_list 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>
最終我能實現的效果,看能不能幫到你,我只想和大家一起分享自己的技術成果