How do I differentiate between Midp 2.0 and 2.1 and Android from a WAP browser so as to redirect them to different location to download the app corresponding to their mobile.
Asked
Active
Viewed 818 times
1 Answers
2
It's pretty difficult to catch all cases correctly, and anyone can always just set their User-Agent to a different value, but the general way to do it in php
is:
Automatically, with
get_browser()
, which requires an up-to-date version of browscap.ini$browserInfo = get_browser(); if($browserInfo->platform === "Android") { // deliver Android link } else if($browserInfo->platform === "JAVA") { // MIDP // deliver MIDP link }
Manually, by running a bunch of regex strings against
$_SERVER['HTTP_USER_AGENT']
. Very generic matches could be done on.*MIDP.*
and.*Android.*
if you want to do it this way.if(preg_match("/.*Android.*/", $_SERVER['HTTP_USER_AGENT'])) // Android { // deliver Android link } else if(preg_match("/.*MIDP.*/", $_SERVER['HTTP_USER_AGENT'])) { // MIDP // deliver MIDP link }