Use PHP and JavaScript to determine whether a request is from a WeChat browser, phpjavascript_php tutorial

Source: Internet
Author: User

Use PHP and JavaScript to determine if the request is from within the browser, Phpjavascript


Browser's Http_user_agent

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)

Under Android, go back

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 the browser is Micromessenger, and there is a version number, you can also determine whether the phone type of iphone or Android

If you want to do hotlinking

if (Strpos ($_server["Http_user_agent"], "Micromessenger"))  echo "Welcome to WeChat word"; else  echo "http/1.1 401 Unauthorized ";p ublic function Is_weixin () {if (Strpos ($_server[' http_user_agent '], ' Micromessenger ')!== false) {RE Turn true;} return false;}    

JS Judgment
function Is_weixin () {  var ua = Navigator.userAgent.toLowerCase ();  if (Ua.match (/micromessenger/i) = = "Micromessenger") {    return true;   } else {    return false;}  }

When the browser is judged on the phone, you can use the Share JS script to deal with it, you can refer to the official documents, here to provide a case, to understand the approximate process and ideas

                

http://www.bkjia.com/PHPjc/1049143.html www.bkjia.com true http://www.bkjia.com/PHPjc/1049143.html techarticle use PHP and JavaScript to determine whether the request comes from within the browser, Phpjavascript browser http_user_agent under iphone, return to mozilla/5.0 (iphone; CPU iPhone OS 5_1 like ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.