Hey all,
I'm in need of a way to detect mobile browsers server-side. I've heard of various ways to do this, but i'd like a way that requires me to do little to set up and little to maintain, yet still provide me with accurate detection of (at the VERY least) android, iphone/ipod, and blackberry browsers, along with alternatives like opera. So, in short, i'd like to have at least the majority of the mobile market covered, and I'd really prefer virtually all of the market if it doesn't take much.
Any suggestions?
Thanks,
-Trey
views:
85answers:
4Its just a matter of reading the headers ( http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php ) and parsing / interpreting this to read the "user-agent", you may be able to find an existing PHP script or maybe just plain regex that will help in figuring out which user-agents are mobile and which are regular pc's / laptops.
There are a lot of different headers, as it indicates the operating system, so as many different mobile OS'es as there are there would be user-agent headers so the script needs to have a list of all valid ones.
WURLF is the ultimate way for mobile browser detection and a PHP API is available.
All you need is get_browser() and a recent browscap.ini that maps the user-agent string to a browser/version and its capabilities.
You can get a usually very up-to-date browscap.ini version from http://browsers.garykeith.com/downloads.asp
How about http://code.google.com/p/hdapi/ ? Server side mobile detection in PHP.