$ua = $_SERVER['HTTP_USER_AGENT']; $da_cache_provider = new Mobi_Mtld_DA_CacheProvider_FileCacheProvider(); $da_api_cached = new Mobi_Mtld_DA_ApiCached("json/sample.json", $da_cache_provider); $properties = $da_api_cached->getProperties($ua);Client side properties Client side properties can be collected and merged into the results by using the DeviceAtlas Javascript detection file. The results from the client side are sent to the server inside a cookie. The contents of this cookie can be passed to the DeviceAtlas getProperty and getProperties methods. The client side properties over-ride any data file properties and also serve as an input into additional logic to determine other properties such as the iPhone models that are otherwise not detectable. The following code shows how this can be done:
$ua = $_SERVER['HTTP_USER_AGENT']; // Get the cookie containing the client side properties $cookie_contents = null; if (isset($_COOKIE['DAPROPS'])){ $cookie_contents = $_COOKIE['DAPROPS']; } $da_cache_provider = new Mobi_Mtld_DA_CacheProvider_FileCacheProvider(); $da_api_cached = new Mobi_Mtld_DA_ApiCached("json/sample.json", $da_cache_provider); $properties = $da_api_cached->getProperties($ua, $cookie_contents);Note: It is not recommended to use ApiCached extension for batch processing (i.e. multiple User-Agent detections during a single request). In these situations use standard API interface. See Api.php for more information
Mobi_Mtld_DA_ApiCached $obj = new Mobi_Mtld_DA_ApiCached( string $pathToJson, Mobi_Mtld_DA_CacheProvider_CacheProviderInterface $cacheProvider, boolean $useTreeOptimizer, string $treeOptimizerCacheDir, boolean $includeChangeableUserAgentProperties )
Creates new instance of Mobi_Mtld_DA_ApiCached object
void $obj->clearTreeOptimizerCache()
Deletes all TreeOptimizer cache files
array $obj->getProperties(string $userAgent, string | null $cookie)
Returns an array of known properties (as strings) for the user agent
string $obj->getProperty(string $userAgent, string $property, string | null $cookie)
Returns a value for the named property for this user agent
void $obj->populateTreeOptimizerCache()
Automatically populate full TreeOptimizer cache
void $obj->setUseSysTempDir(boolean $useSysTempDir)
DEPRECATED, not functional