Use PHP and JavaScript to determine whether the request comes from an internal browser, phpjavascript
HTTP_USER_AGENT of the browser
Under the iPhone, return
Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2)
In Android
Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255)
It is not difficult to find that the browser is MicroMessenger and has a version number. You can also determine whether the mobile phone type is iPhone or Android.
If you want to perform leeching
If (strpos ($ _ SERVER ["HTTP_USER_AGENT"], "MicroMessenger") echo "Welcome to wechat word"; else echo "http/1.1 401 Unauthorized "; public function is_weixin () {if (strpos ($ _ SERVER ['HTTP _ USER_AGENT '], 'micromessenger ')! = False) {return true;} return false;} if ($ this-> is_weixin () {} else {echo "please visit this website. ";}
Js judgment
function is_weixin(){ var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i)=="micromessenger") { return true; } else { return false; }}
After the browser is determined on the mobile phone end, you can use the share js script to process it. For details, refer to the official document. Here is a case study to learn about the general process and ideas.
<Script type = "text/javascript" src = "/jslib/wx_mongo.js"> </script> <script> // rewrite the title, thumbnail, and link of a shared link. introduction and other var imgUrl = '<? Php echo base_url ('/images/per.png');?> '; Var lineLink = 'HTTP: // www.baidu.com/'; var comment title =' I am here to give you money '; var descContent =' refractive index, what do you know? '; Var timeline_title = 'timeline _ title'; var appid = ''; </script> <script> function onBridgeReady () {WeixinJSBridge. call ('showoptionmenu ') ;}</script> <script> if (typeof WeixinJSBridge = "undefined") {if (document. addEventListener) {document. addEventListener ('weixinjsbridgeready', onBridgeReady, false);} else if (document. attachEvent) {document. attachEvent ('weixinjsbridgeready', onBridgeReady); document. attachEvent ('onweixinjsbridgeready', onBridgeReady) ;}} else {onBridgeReady () ;}</script>