GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOBILE::USERAGENT (3)

.ds Aq ’

NAME

Mobile::UserAgent - mobile user agent string parsing class

CONTENTS

SYNOPSIS



  ### Print the information parsed from a user-agent string:
  use Mobile::UserAgent;
  my $useragent = Nokia6600/1.0 (4.09.1) SymbianOS/7.0s Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0;
  my $uaobj = new Mobile::UserAgent($useragent);
  if ($uaobj->success()) {
    print Vendor:     . $uaobj->vendor() . "\n";
    print Model:      . $uaobj->model() . "\n";
    print Version:    . $uaobj->version() . "\n";
    print Series60:   . $uaobj->isSeries60() . "\n";
    print Imode?:     . $uaobj->isImode() . "\n";
    print Mozilla?:   . $uaobj->isMozilla() . "\n";
    print Standard?:  . $uaobj->isStandard() . "\n";
    print Rubbish?:   . $uaobj->isRubbish() . "\n";
  }
  else {
    print "Not a mobile user-agent: $useragent\n";
  }


  ### Determine if the client is a mobile device.
  use Mobile::UserAgent ();
  use CGI ();

  # Check 1: (check if it sends a user-agent profile URL in its headers)
  foreach my $name (X_WAP_PROFILE,PROFILE,13_PROFILE,56_PROFILE) {
    if (exists($ENV{"HTTP_$name"})) {
      print "Client has a user-agent profile header, so its probably a mobile device.\n";
      last;
    }
  }

  # Check 2: (check if it supports WML):
  my $q = new CGI();
  if ($q->Accept(text/vnd.wap.wml) == 1) {
    print "Client supports WML so its probably a mobile device.\n";
  }

  # Check 3: (check if this class can parse it)
  my $uaobj = new Mobile::UserAgent();
  if ($uaobj->success()) {
    print "Clients user-agent could be parsed, so its a mobile device.\n";
  }



DESCRIPTION

Parses a mobile user agent string into it’s basic constituent parts, the most important being vendor and model.

One reason for doing this would be to use this information to lookup vendor-model specific device characteristics in a database. You can use also use user agent profiles to do this (for which I’ve developed other classes), but not all mobile phones have these, especially the older types. Another reason would be to detect if the visiting client is a mobile handset.

Only real mobile user-agent strings can be parsed succesfully by this class. Most WAP emulators are not supported because they usually don’t use the same user-agent strings as the devices they emulate.

CONSTRUCTOR

$mua = Mobile::UserAgent->new( [$useragent] ) This class method constructs a new Mobile::UserAgent object. You can either pass a user-agent string as parameter or else let the constructor try to extract it from the HTTP_USER_AGENT environment variable.

PUBLIC OBJECT METHODS

The public object methods available are:
$mua->success() Returns true if the user-agent string passed into the constructor could be parsed, else false. If this method returns false, then it’s probably not a mobile user agent string that was passed into the constructor.
$mua->userAgent() Returns the user agent string as passed into the constructor or read from the environment variable HTTP_USER_AGENT.
$mua->vendor() Returns the vendor of the handset if success() returns true, else undef.
$mua->model() Returns the model of the handset if success() returns true, else undef.
$mua->version() Returns the version part, if any, of the parsed user-agent string, else undef. The version information is often not present or unreliable.
$mua->isImode() Determines if the parsed user-agent string belongs to an i-mode handset. Returns a boolean. Examples of such user-agent strings:



 portalmmm/1.0 m21i-10(c10)
 portalmmm/1.0 n21i-10(c10)
 portalmmm/1.0 n21i-10(;ser123456789012345;icc1234567890123456789F)
 portalmmm/2.0 N400i(c20;TB)
 portalmmm/2.0 P341i(c10;TB)
 DoCoMo/1.0/modelname
 DoCoMo/1.0/modelname/cache
 DoCoMo/1.0/modelname/cache/unique_id_information
 DoCoMo/2.0 modelname(cache;individual_identification_information)



$mua->isMozilla() Determines if the parsed user-agent string has a Mozilla ’compatible’ format. Returns a boolean. Examples of such user-agent strings:



 Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 3650;424) Opera 6.10  [en]
 Mozilla/4.0 (compatible; MSIE 6.0; Nokia7650) ReqwirelessWeb/2.0.0.0
 Mozilla/1.22 (compatible; MMEF20; Cellphone; Sony CMD-Z5)
 Mozilla/1.22 (compatible; MMEF20; Cellphone; Sony CMD-Z5;Pz063e+wt16)
 Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)
 mozilla/4.0 (compatible;MSIE 4.01; Windows CE;PPC;240X320) UP.Link/5.1.1.5
 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)
 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; SmartPhone; 176x220)
 Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; 240x320; PPC)
 Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; Smartphone; 176x220; Mio8380; Smartphone; 176x220)
 Mozilla/4.0 (MobilePhone SCP-8100/US/1.0) NetFront/3.0 MMP/2.0
 Mozilla/2.0(compatible; MSIE 3.02; Windows CE; Smartphone; 176x220)
 Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS Series 60 42) Opera 6.0 [fr]
 Mozilla/SMB3(Z105)/Samsung UP.Link/5.1.1.5



$mua->isStandard() Determines if the parsed user-agent string has a standard vendor-model/version format. Returns a boolean. Examples of such user-agent strings:



 Nokia8310/1.0 (05.57)
 NokiaN-Gage/1.0 SymbianOS/6.1 Series60/1.2 Profile/MIDP-1.0 Configuration/CLDC-1.0
 SAGEM-myX-6/1.0 UP.Browser/6.1.0.6.1.c.3 (GUI) MMP/1.0 UP.Link/1.1
 SAMSUNG-SGH-A300/1.0 UP/4.1.19k
 SEC-SGHE710/1.0



$mua->isRubbish() Determines if the parsed user-agent string has a non-standard or messed up (to put it in general-public-friendly words) format. Returns a boolean. Examples of such user-agent strings:



 LGE/U8150/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.0
 PHILIPS855 ObigoInternetBrowser/2.0
 PHILIPS 535 / Obigo Internet Browser 2.0
 PHILIPS-FISIO 620/3
 PHILIPS-Fisio311/2.1
 PHILIPS-FISIO311/2.1
 PHILIPS-Xenium9@9 UP/4.1.16r
 PHILIPS-XENIUM 9@9/2.1
 PHILIPS-Xenium 9@9++/3.14
 PHILIPS-Ozeo UP/4
 PHILIPS-V21WAP UP/4
 PHILIPS-Az@lis288 UP/4.1.19m
 PHILIPS-SYSOL2/3.11 UP.Browser/5.0.1.11
 Vitelcom-Feature Phone1.0 UP.Browser/5.0.2.2(GUI
 ReqwirelessWeb/2.0.0 MIDP-1.0 CLDC-1.0 Nokia3650
 SEC-SGHE710



$mua->imodeCache() Returns the maximum i-mode cache data size in kb’s of the user agent if it is an i-mode user-agent, else undef.
$mua->screenDims() Returns the screen dimensions in the format wxh if this information was parsed from the user agent string itself, else undef. Only a few handsets contain this information in the user-agent string such as these that use operating systems from the company I hate most:



 mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)
 mozilla/4.0 (compatible;MSIE 4.01; Windows CE;PPC;240X320) UP.Link/5.1.1.5
 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)
 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; SmartPhone; 176x220)
 Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; 240x320; PPC)
 Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; Smartphone; 176x220; Mio8380; Smartphone; 176x220)
 Mozilla/4.0 (MobilePhone SCP-8100/US/1.0) NetFront/3.0 MMP/2.0
 Mozilla/2.0(compatible; MSIE 3.02; Windows CE; Smartphone; 176x220)



$mua->isSeries60 Determines if the parsed user-agent string belongs to a Symbian OS Series 60 handset. Examples of such user-agent strings:



 NokiaN-Gage/1.0 SymbianOS/6.1 Series60/1.2 Profile/MIDP-1.0 Configuration/CLDC-1.0
 Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS Series 60 42) Opera 6.0 [fr]
 Nokia6600/1.0 (4.09.1) SymbianOS/7.0s Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0



DEVELOPERS

Co-developers are very welcome. Please let me know if you want to help maintain this class. Since the mobile world is evolving rapidly, this class will have to keep up with it when new vendors and standards emerge in user-agent strings.

The project homepage is: http://sourceforge.net/projects/mobileuseragent/

RESOURCES

http://sourceforge.net/projects/mobileuseragent/

http://www.handy-ortung.com

http://www.mobileopera.com/reference/ua

http://www.appelsiini.net/~tuupola/php/Imode_User_Agent/source/

http://www.zytrax.com/tech/web/mobile_ids.html

http://webcab.de/wapua.htm

http://www.nttdocomo.co.jp/english/p_s/i/tag/s2.html

http://test.waptoo.com/v2/skins/waptoo/user.asp

COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

AUTHOR

Craig Manley
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOBILE::USERAGENT (3) 2005-09-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.