I downloaded the API kit for PHP and went through the code and am a bit lost. I want to direct the viewer to a site based on device and brower type.
I want to be able to do the following:
if it is an iphone or a phone with a large screen, direct them to
http://www.gaya3in1.kroute.com/iphone/iphone.html
if it is a balck berry or a phone with a screen size 2inchs by 2 inches, direct them to
http://www.gaya3in1.kroute.com/phone/phone.html
if it firefox or windows, direct them to default
http://www.gaya3in1.kroute.com
if it another browser, direct them to a page where they can choose between a simple vs loaded page
http://www.gaya3in1.kroute.com/option.htm
Thank you.
November 30, 2009 09:00
support
Handset Detection
Hi Gaya3in1,
Please save the following code as devices.detect.own.php in the \'hdapi\' folder, then upload them to your web server, add this line:
require_once \"devices.detect.own.php\"
to your index file on your web server.
getData which will return an array of all matching data.
$hd = new HandsetDetection();
// Read in your server variables for detection.
$hd->detectInit();
// Fake up a Nokia N95 query (This is just here to demonstrate things working)
// In the real world you would remove this line.
//$hd->setDetectVar(\'user-agent\', \'Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95/12.0.013; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413\');
$hd->setDetectVar(\'user-agent\',\'Nokia1100\');
// Now lets detect that.
$ret = $hd->detect();
if ($ret) {
if ($hd->mobile_site != \'\') {
$getMobileInfo=$hd->getDetect();
$vendor=$getMobileInfo[\'product_info\'][\'brand_name\'];
$model=$getMobileInfo[\'product_info\'][\'model_name\'];
$screen_height=$getMobileInfo[\'display\'][\'resolution_height\'];
$screen_width=$getMobileInfo[\'display\'][\'resolution_width\'];
if( ($vendor==\'Apple\' && $model==\'iPhone\')
|| ($screen_height>=300 && $screen_width>=300)){
//iPhone or large size screen
header(\'location: http://www.gaya3in1.kroute.com/iphone/iphone.html\');
}else{
if(($vendor==\'RIM\' && substr($model,0,10)==\'BlackBerry\')
|| ($screen_height>=200 && $screen_width>=200)){
//BlackBerry or screen with size 2 inchs
header(\'location: http://www.gaya3in1.kroute.com/phone/phone.html\');
}else{
//others conditions
if(strstr($_SERVER[\'HTTP_USER_AGENT\'],\'MSIE\')){
//Firefox 4 or compatible MSIE etc.
header(\'Location: http://www.gaya3in1.kroute.com\');
}else{
//other browser
header(\'Location: http://www.gaya3in1.kroute.com/option.htm\');
}
}
}
}
}
?>
November 30, 2009 17:25
support
Handset Detection
Wow, that looks terrible.
drop me a email and I will reply with this file.
Thanks,
Bill
bill@handsetdetection.com
Comments
getData which will return an array of all matching data. $hd = new HandsetDetection(); // Read in your server variables for detection. $hd->detectInit(); // Fake up a Nokia N95 query (This is just here to demonstrate things working) // In the real world you would remove this line. //$hd->setDetectVar(\'user-agent\', \'Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95/12.0.013; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413\'); $hd->setDetectVar(\'user-agent\',\'Nokia1100\'); // Now lets detect that. $ret = $hd->detect(); if ($ret) { if ($hd->mobile_site != \'\') { $getMobileInfo=$hd->getDetect(); $vendor=$getMobileInfo[\'product_info\'][\'brand_name\']; $model=$getMobileInfo[\'product_info\'][\'model_name\']; $screen_height=$getMobileInfo[\'display\'][\'resolution_height\']; $screen_width=$getMobileInfo[\'display\'][\'resolution_width\']; if( ($vendor==\'Apple\' && $model==\'iPhone\') || ($screen_height>=300 && $screen_width>=300)){ //iPhone or large size screen header(\'location: http://www.gaya3in1.kroute.com/iphone/iphone.html\'); }else{ if(($vendor==\'RIM\' && substr($model,0,10)==\'BlackBerry\') || ($screen_height>=200 && $screen_width>=200)){ //BlackBerry or screen with size 2 inchs header(\'location: http://www.gaya3in1.kroute.com/phone/phone.html\'); }else{ //others conditions if(strstr($_SERVER[\'HTTP_USER_AGENT\'],\'MSIE\')){ //Firefox 4 or compatible MSIE etc. header(\'Location: http://www.gaya3in1.kroute.com\'); }else{ //other browser header(\'Location: http://www.gaya3in1.kroute.com/option.htm\'); } } } } } ?>