2.2.2 :: getMobileDevice via CURL

getMobileDevice



This function is an advanced version of isMobileDevice. Use this function to determine whether the device is a mobile device and also receive the model and manufacturer of the device.
Parameters:

  • devKey - used for authentication and to log usage.

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


Returns: (string)
Upon success, XML containing mobile device information
Upon failure, error codes WAPL markup

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.  
  3.  $headers = '';
  4.  foreach($_SERVER as $key => $val)
  5.  {
  6.   $headers .= $key.':'.$val.'|';
  7.  }
  8.  
  9.  $postfields = array(
  10.   'devKey' => 'YOUR_DEV_KEY',
  11.   'headers' => $headers
  12.  );
  13.  
  14.  $c = curl_init();
  15.  curl_setopt($c, CURLOPT_URL, 'http://webservices.wapple.net/getMobileDevice.php');
  16.  curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  17.  curl_setopt($c, CURLOPT_POST, 1);
  18.  curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
  19.  
  20.  $result = curl_exec($c);
  21.  $xml = simplexml_load_string($result);
  22.  curl_close($c);
  23.  
  24.  if (trim($xml->mobile_device) == 1)
  25.  {
  26.   echo '<pre>';
  27.   echo 'I AM A MOBILE DEVICE'."\n";
  28.   echo 'Manufacturer: '.trim($xml->manufacturer)."\n";
  29.   echo 'Model: '.trim($xml->model)."\n";
  30.   echo '</pre>';
  31.  } else
  32.  {
  33.   $isMobile = false;
  34.  }
  35.  ?>

Contents