How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site

Forums » Tutorial And Guides » How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site
This Page Contains information about How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site By wallpaperama with 8 Replies. Last Upated: Mon Apr 21, 2014
now a days you can put wallpapers anywhere, its not just for desktops anymore
its for laptops, pda's, cellphones, smart phones etc..

so there will come a time when you will have to provide content for wurl users

so just how can you detect if a user is using a cell phone when they visit your site.

there are a number of way, the easiest i know how is to do it server side

with php you can do that

php is very powerful programming language that lets you do alot of things for your website

so often i used this function or class to detect if a user visiting my site is coming from a mobile device or not

<?php

function checkmobile(){

if(isset($_SERVER["HTTP_X_WAP_PROFILE"])) return true;

if(preg_match("/wap.|.wap/i",$_SERVER["HTTP_ACCEPT"])) return true;

if(isset($_SERVER["HTTP_USER_AGENT"])){

$uamatches = array("midp", "j2me", "avant", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows ce", "mmp/", "blackberry", "mib/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up.b", "audio", "SIE-", "SEC-", "samsung", "HTC", "mot-", "mitsu", "sagem", "sony", "alcatel", "lg", "eric", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "dddi", "moto");

foreach($uamatches as $uastring){
if(preg_match("/".$uastring."/i",$_SERVER["HTTP_USER_AGENT"])) return true;
}

}
return false;
}

if(checkmobile()){
echo '
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<title>Google</title>
</head>
<body>
Hello Mobile User, Welcome to Wallpaperama.com
</body>

</html>

';
}else{
echo 'NOT you are using a mobile phone';
}

?>


check it out, if you have a mobile phone or device and you are have access to internet, go to
http://www.wallpaperama.com and you will be automatically directed to our mobile website

Try it!!

david
to actually detect what device is browsing your site, or requesting the mobile content, you can use handsetdetection which actually tells you the screen size of the device and other device characteristics
http://wallpaperama.com/forums/how-to-detect-mobile-browsers-wireless-cellphone-users-visiting-your-site-t5907.html
Klint
redirection is important but once the user lands on your mobile site you'll need to make sure the mobile site is working on all mobile phones. you'll need at some point a mobile detection system that will provide you with phone specifications like this:
mobilemultimedia.be (online)
wurfl.sourceforge.net (online and offline)
Amit
you can easily determine that a request is coming from a what mobile device using 51degrees.mobi/products/netmobileap

apart from identifying mobile devide this api gives detailed information of the device making the request and also has the facility to redirect user automatically to mobile specific page when request in coming from mobile device.

i found this more powerful and easy to implement in my mobile website developments.

thanks
Amit
sorry url was not proper in last post.

51degrees.mobi/product
Amit
editor is not accepting urls so here is the way to go for info.

- please goto 51degrees.mobi website
- look for products->netmobileapi
Siddharth
Hey this is the gr8 stuff but it fails when i try to open it useing i-phone,why it is so
Meghan
hey, i love it cellphonebeta.
Meghan
the quality of it is satisfying, and the function is easy to perform
Title: How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site [1435]
Tags: how to detect mobile browsers wireless cellphone users visiting your site
By , 8 Comments