导读:
最近遇到一个问题,我的网站域名(正规网站)被oppo内置浏览器给拦截了,我提交申诉一两个月了,都没有工作人员处理,可见oppo浏览器非常的不称职,建议大家不要用。拦截申诉不了,那怎么办呢?解决方法就是检测用户访问的浏览器唯一标识useragent,如果是oppo浏览器,就提示让用户选择更好的浏览器。
一、useragent是什么?
useragent,顾名思义,就是用户代理,他是一个字符串,用于向服务器表明客户端身份的作用。服务端根据这个字符串,来确定如何以最佳的方式展现内容给客户端。比如手机端访问网站,对其重定向到手机版网站。
二、使用PHP获取访问浏览器的useragent
1、获取useragent
<?php $browser = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : ""; echo $browser;die;
2、判断是不是oppo内置浏览器
public function index(){ $browser = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : ""; //如果是oppo浏览器 if(!empty($browser) && stripos($browser, "HeyTapBrowser") !== false){ exit("系统检测到您当前使用的浏览器比较落后,建议更换其他浏览器,比如谷歌浏览器、QQ浏览器等!"); } return view(); }
三、各类浏览器的useragent:
1、IE10
Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)
2、iPhone6
Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25
3、iPad
Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25
4、Android
Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36
5、google chrome
Mozilla/5.0 (Windows NT 5.2) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30
6、firefox
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
7、Opera
Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.9.168 Version/11.50
8、Safari
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
9、Windows Phone
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)
10、微信内置浏览器(核心标识:MicroMessenger )
Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a MicroMessenger/6.2.1
11 、搜狗浏览器
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)
12、360浏览器
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; 360se)
13、腾讯浏览器
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; TencentTraveler 4.0; .NET CLR 2.0.50727)
14、今日头条app内置浏览器的useragent:NewsArticle、TTWebView
Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 NewsArticle/8.7.6.20 JsSdk/2.0 NetType/WIFI (News 8.7.6 15.400000)
Mozilla/5.0 (Linux; Android 10; ELE-AL00 Build/HUAWEIELE-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.156 Mobile Safari/537.36 TTWebView/0751130035403
15、vivo手机浏览器 VivoBrowser
Mozilla/5.0 (Linux; Android 8.1.0; vivo X20A Build/OPM1.171019.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/87.0.4280.141 Mobile Safari/537.36 VivoBrowser/10.8.16.0
16、华为手机浏览器 HuaweiBrowser
Mozilla/5.0 (Linux; Android 10; HarmonyOS; JEF-AN00; HMSCore 6.2.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.1.300 Mobile Safari/537.36
17、OPPO手机内置浏览器 HeyTapBrowser
Mozilla/5.0 (Linux; U; Android 11; zh-cn; PDRM00 Build/RKQ1.200903.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 HeyTapBrowser/40.7.27.2
18、搜狗手机app内置浏览器 SogouMobileBrowser
Mozilla/5.0 (Linux; Android 10; G0515D Build/QKQ1.200913.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/68.0.3440.106 Mobile Safari/537.36 AWP/2.0 SogouMSE,SogouMobileBrowser/5.23.57
19、UC手机浏览器 UCBrowser
Mozilla/5.0 (Linux; U; Android 11; zh-CN; M2011K2C Build/RKQ1.200928.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 UCBrowser/13.8.0.1161 Mobile Safari/537.36
20、小米手机内置浏览器 MiuiBrowser
Mozilla/5.0 (Linux; U; Android 12; zh-cn; 2201122C Build/SKQ1.211006.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.116 Mobile Safari/537.36 XiaoMi/MiuiBrowser/15.9.18 swan-mibrowser
21、QQ浏览器手机版 MQQBrowser
Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 MQQBrowser/9.6.0 Mobile/15E148 Safari/604.1 QBWebViewUA/2 QBWebViewType/1 WKType/1
22、手机百度app内置浏览器 baiduboxapp
Mozilla/5.0 (Linux; Android 11; M2006J10C Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 Mobile Safari/537.36 T7/13.8 SP-engine/2.46.0 baiduboxapp/13.8.1.10 (Baidu; P1 11) NABar/1.0