Last active
October 29, 2015 09:55
-
-
Save Illvili/cbf694383801556280ac to your computer and use it in GitHub Desktop.
APP QR Download Detect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 地址配置 | |
$iOSAPPStoreLink = '[iOS APP Store Link here]'; | |
$AndroidLink = '[APK Link here]'; | |
function redirect($url) { | |
header('Location: ' . $url); | |
exit(); | |
} | |
// 获取UA | |
$userAgent = $_SERVER['HTTP_USER_AGENT']; | |
// 检测 | |
$is_iOS = !!preg_match('/(iPad|iPhone|iPod)/i', $userAgent); | |
$is_Android = false !== strpos($userAgent, 'Android'); | |
$is_MicroMessenger = false !== strpos($userAgent, 'MicroMessenger'); | |
$is_FromWXMenu = isset($_GET['f']) && 'wxm' == $_GET['f']; | |
if ($is_iOS) { | |
if (!$is_FromWXMenu && !$is_MicroMessenger) { | |
redirect($iOSAPPStoreLink); | |
} | |
} else if ($is_Android) { | |
if (!$is_MicroMessenger) { | |
redirect($AndroidLink); | |
} | |
} else { | |
redirect('[APP Description Page Link here]'); | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta charset="UTF-8"> | |
<title>移动客户端下载</title> | |
<style> | |
body { | |
background: #f0f0f0; | |
color: #333; | |
text-shadow: 1px 1px 0 #fff; | |
-webkit-text-shadow: 1px 1px 0 #fff; | |
font-size: 16px; | |
text-align: center; | |
line-height: 2; | |
padding-top: 40px; | |
} | |
</style> | |
</head> | |
<body> | |
您当前正在使用微信<?php if (!$is_FromWXMenu) : ?>扫一扫<?php endif ?><br>请点击右上角菜单选择“在浏览器中打开” | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
微信公众菜单打开页面测试情况
HTTP Header
跳转Javascript
跳转HTML
A链接