Issue getting correct headers from Opera Mini

741 views Asked by At

For all of our mobile sites we log all incoming requests to our pages via a PHP script. We get thousands of hits each day from Opera mini and we have been using the code snippet below to determine the correct user agent.

if (array_key_exists("X-OperaMini-Phone", $headers))
{
$ua= mysql_real_escape_string('Opera-').($headers["X-OperaMini-Phone"]);
}
else 

{ $ua = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); }

However, after running this for some time I find that in the vast majority of cases the X-OperaMini-Phone header is blank. Does the code above look correct? And if so, can you shed some light on why?

1

There are 1 answers

5
Ameer On

It is more advisable to look for the string "Opera Mini" in the UA string while detecting Opera Mini. X-OperaMini-Phone header may not be reported by all devices. Refer here for details. http://dev.opera.com/articles/view/opera-mini-request-headers/