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
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
- <SOAP-ENV:Body>
- <ns1:isMobileDevice>
- <devKey>Wapple</devKey>
- <deviceHeaders>
- <deviceItem>
- <name>HTTP_HOST</name>
- <value>wapple.net</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_USER_AGENT</name>
- <value>LGE-LG380/1.0 UP.Browser/6.2.3.8 (GUI) MMP/2.0</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_CHARSET</name>
- <value>utf-8</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_LANGUAGE</name>
- <value>en; q=1.0, en, *; q=0.5</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_ENCODING</name>
- <value>deflate,gzip</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_REFERER</name>
- <value>http://www.wapple.net/</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_CACHE_CONTROL</name>
- <value>max-age=259200</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_CONNECTION</name>
- <value>keep-alive</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT</name>
- <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>
- </deviceItem>
- </deviceHeaders>
- </ns1:isMobileDevice>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
Example SOAP Response
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
- <SOAP-ENV:Body>
- <ns1:isMobileDeviceResponse>1</ns1:isMobileDeviceResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
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.
- <?php
- try {
- $sClient = @new SoapClient('http://webservices.wapple.net/wapl.wsdl', array('connection_timeout' => 5));
- $isMobile = false;
-
- if($sClient)
- {
- $headers = array();
- foreach($_SERVER as $key => $val)
- {
- $headers[] = array('name' => $key, 'value' => $val);
- }
- // check if we are a mobile device
- $params = array(
- 'devKey' => "YOUR-DEV-KEY",
- 'deviceHeaders' => $headers
- );
-
- if($sClient->isMobileDevice($params))
- {
- // A mobile device !!
- $isMobile = true;
- }
- }
-
- } catch (Exception $e){
- // Add your own exception handling here
- }
- ?>