相同的请求,php怎么判断来自wap还是app的webview加载?

WBOY
Release: 2016-06-06 20:25:35
Original
1612 people have browsed it

我的同一个页面,现在想区分wap还是app进行模板制作,怎么区分?

回复内容:

我的同一个页面,现在想区分wap还是app进行模板制作,怎么区分?

通过HTTP头中的User-Agent来区分

app自家的话,可以自定义一个User-Agent


在不改变app代码的情况下,iOS APP的UA是这样的:

Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13B137

微信:

Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13B143 MicroMessenger/6.3.6 NetType/WIFI Language/zh_CN

Safari:

Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1

可以看到APP默认,微信和safari各不相同,还是可以做出区别的

Android的我手边暂时没有设备,你可以自己试试看看

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template