Detecting Mobile User-Agent For OperaMini Client
Mobile phone that use OperaMinisometimes don't sent user agent header to the server. Instead, they send:
Opera/9.60 (J2ME/MIDP; Opera Mini/4.1.13068/488; U; en) Presto/2.2.0
This can cause a problem for web application that rely on user-agent detection, such as application that use WURFL So, after about an hour or two trying to debug the problem, I found some way to retrieve the original user-agent (device user-agent) instead of operamini user-agent.
The solution is to check for the existence of X-OperaMini-Phone-UA header. In PHP, it can be as simple as:
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ( stristr( $user_agent, 'Opera Mini' ) ) {
//its opera mini, try the X-OperaMini-Phone-UA
$user_agent = isset( $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] ) ? $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] : $user_agent;
}
//do your rest of the stuff here
So, now phone detection using user_agent will work as normal, even if the user use Opera Mini browser.
hello world
what about native browser for SE phones? same method?
native browser like SonyEricsson's NetFront will sent native user-agent. For example, my K800i sent:
SonyEricssonK800i/R1JG Release/Feb-15-2007 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 UNTRUSTED/1.0
you might want to consider one of the many web services out there like handsetdetection.com which interface with the wurfl database of devices.
it is compatible with detection of opera mini and the other non-native browser user agent strings...