| 
<?php
/*
 example usage
 userStack ver 1.0
 
 You must get an API key from https://userstack.com/product
 and enter it in the userstack.class.php file
 */
 
 //turning off low level notices
 error_reporting(E_ALL ^ E_NOTICE);
 
 //instantiate the class
 include('userstack.class.php');
 $userStack = new userStack();
 
 //set the user agent to be checked
 $ua = $_SERVER['HTTP_USER_AGENT'];
 $userStack->setParam('ua',$ua);
 
 //get the response from the api
 $userStack->getResponse();
 
 //the response property will contain the response returned from the api
 echo '<h4>API response for user agent: '.$ua.'</h4>';
 echo 'Operating System: '.$userStack->response->os->name.'<br>';
 echo 'Device: '.$userStack->response->device->type.'<br>';
 echo 'Browser: '.$userStack->response->browser->name.'<br>';
 
 //full response
 echo '<hr>';
 echo '<h4>Full response</h4>';
 echo '<pre>';
 var_dump($userStack->response);
 echo '</pre>';
 
 ?>
 
 |