Blogging / Computer projects / Networking

Using PHP to detect visits from WeChat's built-in browser

<?php
if (is_weixin()) {
    echo "这是微信内部浏览器";
} else {
    echo "这是微信外部浏览器";
}

function is_weixin() {
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
        return true;
    }
    return false;
}
?>

wechat-tencent.jpg

Published 02/11/2019 · Krunk Zhou

Join the conversation