2.1.1 :: isMobileDevice

isMobileDevice



Use this function to determine whether the device is a mobile device.

Function:
isMobileDevice(devKey, headers)

Parameters:

  • devKey - used for authentication and to log usage.

  • headers - the headers of the device you wish to query.



Returns: (int)
1 : This is a mobile device
0 : Device is not mobile

Example SOAP Request


  1.  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
  2.   <SOAP-ENV:Body>
  3.   <ns1:isMobileDevice>
  4.   <devKey>Wapple</devKey>
  5.   <deviceHeaders>
  6.   <deviceItem>
  7.   <name>HTTP_HOST</name>
  8.   <value>wapple.net</value>
  9.   </deviceItem>
  10.   <deviceItem>
  11.   <name>HTTP_USER_AGENT</name>
  12.   <value>LGE-LG380/1.0 UP.Browser/6.2.3.8 (GUI) MMP/2.0</value>
  13.   </deviceItem>
  14.   <deviceItem>
  15.   <name>HTTP_ACCEPT_CHARSET</name>
  16.   <value>utf-8</value>
  17.   </deviceItem>
  18.   <deviceItem>
  19.   <name>HTTP_ACCEPT_LANGUAGE</name>
  20.   <value>en; q=1.0, en, *; q=0.5</value>
  21.   </deviceItem>
  22.   <deviceItem>
  23.   <name>HTTP_ACCEPT_ENCODING</name>
  24.   <value>deflate,gzip</value>
  25.   </deviceItem>
  26.   <deviceItem>
  27.   <name>HTTP_REFERER</name>
  28.   <value>http://www.wapple.net/</value>
  29.   </deviceItem>
  30.   <deviceItem>
  31.   <name>HTTP_CACHE_CONTROL</name>
  32.   <value>max-age=259200</value>
  33.   </deviceItem>
  34.   <deviceItem>
  35.   <name>HTTP_CONNECTION</name>
  36.   <value>keep-alive</value>
  37.   </deviceItem>
  38.   <deviceItem>
  39.   <name>HTTP_ACCEPT</name>
  40.   <value>application/vnd.phonecom.mmc-xml, application/vnd.wap.wmlc;type=4365, application/vnd.wap.wmlscriptc, application/vnd.wap.xhtml+xml, application/xhtml+xml;profile="http://www.wapforum.org/xhtml", image/bmp, image/gif, image/jpeg, image/png, image/vnd.wap.wbmp, image/x-up-wpng, multipart/mixed, multipart/related, text/html, text/plain, text/vnd.wap.wml;type=4365, audio/midi, audio/qcelp, audio/vnd.qcelp, application/x-pmd, audio/mid, audio/x-midi, audio/x-mid, audio/mp4, audio/mp3, audio/mpeg4, video/mpeg4, video/mp4, application/vnd.oma.dd+xml, application/vnd.oma.drm.message</value>
  41.   </deviceItem>
  42.   </deviceHeaders>
  43.   </ns1:isMobileDevice>
  44.   </SOAP-ENV:Body>
  45.  </SOAP-ENV:Envelope>
Downloadlisting 2.1.1.a


Example SOAP Response


  1.  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
  2.   <SOAP-ENV:Body>
  3.   <ns1:isMobileDeviceResponse>1</ns1:isMobileDeviceResponse>
  4.   </SOAP-ENV:Body>
  5.  </SOAP-ENV:Envelope>
Downloadlisting 2.1.1.b


PHP Example


Nb. The example below uses the native PHP soap extension in PHP. The code is for demonstration purposes only and should be modified for use in a production environment.
  1.  <?php
  2.  try {
  3.   $sClient = @new SoapClient('http://webservices.wapple.net/wapl.wsdl', array('connection_timeout' => 5));
  4.   $isMobile = false;
  5.  
  6.   if($sClient)
  7.   {
  8.   $headers = array();
  9.   foreach($_SERVER as $key => $val)
  10.   {
  11.   $headers[] = array('name' => $key, 'value' => $val);
  12.   }
  13.   // check if we are a mobile device
  14.   $params = array(
  15.   'devKey' => "YOUR-DEV-KEY",
  16.   'deviceHeaders' => $headers
  17.   );
  18.  
  19.   if($sClient->isMobileDevice($params))
  20.   {
  21.   // A mobile device !!
  22.   $isMobile = true;
  23.   }
  24.   }
  25.  
  26.  } catch (Exception $e){
  27.   // Add your own exception handling here
  28.  }
  29.  ?>

Contents