1. 程式人生 > >如何判斷是否是微信端登入

如何判斷是否是微信端登入

function is_weixin(){
global $_W;
$useragent = addslashes($_SERVER['HTTP_USER_AGENT']);
if(strpos($useragent, 'MicroMessenger') === false && strpos($useragent, 'Windows Phone') === false ){
 $url="http://qr.liantu.com/api.php?text=".urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
 $html='<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><title>只能在微信中開啟</title><meta name="format-detection" content="telephone=no, address=no" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-touch-fullscreen" content="yes" /></head><body><style>.codeImage table{margin:0 auto;}</style><div class="box" style=" padding-top:1.5rem;min-height:18.45rem;"><div class="codeImage" style="text-align: center;"><img src="'.$url.'" alt="placeholder+image"></div><div class="info" style="margin:auto 0;margin-top:20px;color:#666;text-align: center;font-size: 28px;">請用手機微信掃描二維碼</div></div><script>(function(){var s="_"+Math.random().toString(36).slice(2);document.write(\'<div id="\'+s+\'"></div>\');(window.slotbydup=window.slotbydup||[]).push({id:"4345361",container:s,size:"20,3",display:"inlay-fix"})})();</script><script src="http://dup.baidustatic.com/js/om.js"></script></body></html>';
 echo $html;
 exit;
}
}