try { $data = DeviceAtlasCloudClient::getDeviceData(); } catch (Exception $x) { // handle exceptions ... }
// legacy: (class constant DEBUG = false) // the errors have to be checked manually from the returned array $data = DeviceAtlasCloudClient::getDeviceData();The returned data is as:
$data[DeviceAtlasCloudClient::KEY_ERROR] will exist if errors happened while fetching data $data[DeviceAtlasCloudClient::KEY_PROPERTIES] an array of device properties $data[DeviceAtlasCloudClient::KEY_USERAGENT] the user-agent string that was used to get the properties $data[DeviceAtlasCloudClient::KEY_SOURCE] shows where the data came from and is one of: DeviceAtlasCloudClient::SOURCE_FILE_CACHE DeviceAtlasCloudClient::SOURCE_CLOUD DeviceAtlasCloudClient::SOURCE_NONE
// get properties for a user-agent try { $data = DeviceAtlasCloudClient::getDeviceData("user-agent-string ..."); } catch (Exception $x) { // handle exceptions ... }
// get properties for a set of headers $headers = array( "User-Agent" => "Mozilla/5.0 (SymbianOS/9.2; ...", "X-Profile" => "http://nds.nokia.com/uaprof/NN95_8GB-1r100.xml", "Accept" => "text/html,text/css,multipart/mixed,application...", "Accept-Language" => "en-us,en;q=0.5", ); try { $data = DeviceAtlasCloudClient::getDeviceData($headers); } catch (Exception $x) { // handle exceptions ... }Notes:
DeviceAtlas Cloud API version
Server preferred list will be updated when older than this amount of minutes
When ranking servers, if a server fails more than this number phase it out
Number of requests to send when testing server latency
Cookie cache, cookie name
Cache expire (for both file and cookie) 2592000 = 30 days in seconds
File cache > directory name
Name of the cookie created by "DeviceAtlas Client Side Component"
Max time (seconds) to wait for each cloud server to give service
File cache > this is only used if USE_SYSTEM_TEMP_DIR is false
true = throw exceptions on all errors and failures
Action to be taken after an end-point responds: If an-endpoint response was fine
A key of array returned by getDeviceData() - the error message is set to this key
A key of array returned by getDeviceData() - the device properties are set to this key
A key of array returned by getDeviceData() - the source of data is set to this key
A key of array returned by getDeviceData() - the user-agent is set to this key
Set to your DeviceAtlas licence key
Min DeviceAtlas Cloud API required PHP version
Auto ranking = false > if top server fails it will be phased out for this amount of minutes
Device data source value set to KEY_SOURCE - device data source was cloud service
Device data source value set to KEY_SOURCE - device data source was cookie
Device data source value set to KEY_SOURCE - device data source was file cache
Device data source value set to KEY_SOURCE - no device data, indicates an error
Use device data which is created by the DeviceAtlas Client Side Component if exists
Cache cloud results in cookies
File cache > leave as true to put cache in systems default temp directory
array DeviceAtlasCloudClient::getDeviceData()
Get the device data for the current request from DeviceAtlas Cloud. Once data has been returned from DeviceAtlas Cloud it can be cached locally to speed up subsequent requests. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data. When no parameter is provided the client's headers will be used for detection.
{ DeviceAtlasCloudClient::KEY_USERAGENT: "UA" | null, DeviceAtlasCloudClient::KEY_SOURCE: "data source", DeviceAtlasCloudClient::KEY_PROPERTIES: {"propertyName": "PropertyVal",} | null, DeviceAtlasCloudClient::KEY_ERROR: err-msg-string | null, }
string DeviceAtlasCloudClient::getCloudUrl()
Get the URL of the last DeviceAtlas cloud end-point which was called to get device properties.
string DeviceAtlasCloudClient::getCacheBasePath()
Get the directory path in which the DeviceAtlas CloudApi puts cache files in (device data cache and server fail-over list).
array DeviceAtlasCloudClient::getDeviceData(array headers)
Get the device data for a set of HTTP headers from DeviceAtlas Cloud. Once data has been returned from DeviceAtlas Cloud it can be cached locally to speed up subsequent requests. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data. When no parameter is provided the client's headers will be used for detection.
{ DeviceAtlasCloudClient::KEY_USERAGENT: "UA" | null, DeviceAtlasCloudClient::KEY_SOURCE: "data source", DeviceAtlasCloudClient::KEY_PROPERTIES: {"propertyName": "PropertyVal",} | null, DeviceAtlasCloudClient::KEY_ERROR: err-msg-string | null, }
array DeviceAtlasCloudClient::getDeviceData(string userAgent)
Get the device data for a user-agent string from DeviceAtlas Cloud. Once data has been returned from DeviceAtlas Cloud it can be cached locally to speed up subsequent requests. If device data provided by "DeviceAtlas Client Side Component" exists in a cookie then cloud data will be merged with the cookie data. When no parameter is provided the client's headers will be used for detection.
{ DeviceAtlasCloudClient::KEY_USERAGENT: "UA" | null, DeviceAtlasCloudClient::KEY_SOURCE: "data source", DeviceAtlasCloudClient::KEY_PROPERTIES: {"propertyName": "PropertyVal",} | null, DeviceAtlasCloudClient::KEY_ERROR: err-msg-string | null, }
array DeviceAtlasCloudClient::getDeviceData(bool test)
Get the device data for a built in test user-agent.
{ DeviceAtlasCloudClient::KEY_USERAGENT: "UA" | null, DeviceAtlasCloudClient::KEY_SOURCE: "data source", DeviceAtlasCloudClient::KEY_PROPERTIES: {"propertyName": "PropertyVal",} | null, DeviceAtlasCloudClient::KEY_ERROR: err-msg-string | null, }
array DeviceAtlasCloudClient::getServers()
Get DeviceAtlas cloud end-point list in the same order used by the API. If auto-ranking is on then the ranked end-point list is returned otherwise the manual or the default fail-over list is returned. If auto-ranking is on and the end-point list cache is invalid or out of date then the end-points will be ranked and cached first.
array DeviceAtlasCloudClient::getServersLatencies( int numRequests=DeviceAtlasCloudClient::AUTO_SERVER_RANKING_NUM_REQUESTS )
Get a list of cloud end-points and their service latencies.
array DeviceAtlasCloudClient::rankServers()
If auto-ranking is on then rank the DeviceAtlas cloud end-points and put in cache.