2.2.1 :: isMobileDevice via CURL

isMobileDevice



Use this service to determine whether a visitor is actually a mobile device or not.
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

PHP Example


The example below uses CURL to communicate with Wapple's web services. You could use another method to communicate if you don't have CURL or prefer something else!
  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/isMobileDevice.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.  curl_close($c);
  22.  
  23.  if($result)
  24.  {
  25.   // A mobile device!
  26.   $isMobile = true;
  27.  } else
  28.  {
  29.   $isMobile = false;
  30.  }
  31.  ?>

Contents