\WurflCloud_Client_Client
WURFL Cloud Client for PHP.
Synopsis
class WurflCloud_Client_Client
{
- // constants
- const ERROR_CONFIG = 1;
- const ERROR_NO_SERVER = 2;
- const ERROR_TIMEOUT = 4;
- const ERROR_BAD_RESPONSE = 8;
- const ERROR_AUTH = 16;
- const ERROR_KEY_DISABLED = 32;
- const SOURCE_NONE = 'none';
- const SOURCE_CLOUD = 'cloud';
- const SOURCE_CACHE = 'cache';
- const CLASS_PREFIX = 'WurflCloud_';
- // members
- public array $capabilities = ;
- private array $errors = ;
- private array $search_capabilities = ;
- private array $user_agent_headers = ;
- private $user_agent;
- private $http_request;
- private $wcloud_host;
- private $request_path;
- private $json;
- private array $report_data = ;
- private string $client_version = '1.0.2';
- private $api_version;
- private $api_username;
- private $api_password;
- private $loaded_date;
- private WurflCloud_Client_Config $config;
- private WurflCloud_Cache_CacheInterface $cache;
- private $source;
- private WurflCloud_HttpClient_AbstractHttpClient $http_client;
- private static $base_path;
- // methods
- public void __construct()
- public void detectDevice()
- public void getSource()
- private void initializeRequest()
- public int getLoadedDate()
- private boolean allCapabilitiesPresent()
- private void addReportDataToRequest()
- private void validateCache()
- public mixed getDeviceCapability()
- public string getClientVersion()
- public string getAPIVersion()
- public string getCloudServer()
- private void callWurflCloud()
- private void processResponse()
- private static string|int|boolean|float niceCast()
- private string getUserAgent()
- private boolean splitApiKey()
- public static void loadClass()
Constants
Name | Value |
---|---|
ERROR_CONFIG | 1 |
ERROR_NO_SERVER | 2 |
ERROR_TIMEOUT | 4 |
ERROR_BAD_RESPONSE | 8 |
ERROR_AUTH | 16 |
ERROR_KEY_DISABLED | 32 |
SOURCE_NONE | 'none' |
SOURCE_CLOUD | 'cloud' |
SOURCE_CACHE | 'cache' |
CLASS_PREFIX | 'WurflCloud_' |
Members
private
- $api_password
—
string
The API Password - $api_username
—
integer
The API Username - $api_version
—
string
The version of the WURFL Cloud Server - $base_path — string
- $cache
—
WurflCloud_Cache_CacheInterface
Client cache object - $client_version
—
string
The version of this client - $config
—
WurflCloud_Client_Config
Client configuration object - $errors
—
array
Errors that were returned in the response body - $http_client
—
WurflCloud_HttpClient_AbstractHttpClient
The HTTP Client that will be used to call WURFL Cloud - $http_request
—
array
The HTTP Request that is being evaluated - $json
—
string
The raw json response from the server - $loaded_date
—
int
The date that the WURFL Cloud Server's data was updated - $report_data
—
array
Storage for report data (cache hits, misses, errors) - $request_path
—
string
The request path to the WURFL Cloud Server (e.x. '/v1/json/search:(is_wireless_device)' ) - $search_capabilities
—
array
The capabilities that will be searched for - $source
—
string
The source of the last detection - $user_agent
—
string
The HTTP User-Agent that is being evaluated - $user_agent_headers
—
array
The HTTP Headers that will be examined to find the best User Agent, if one is not specified - $wcloud_host
—
string
The WURFL Cloud Server that will be used to request device information (e.x. 'api.wurflcloud.com')
public
- $capabilities
—
array
Flat capabilities array containing 'key'=>'value' pairs.
Methods
private
- addReportDataToRequest() — Retrieves the report data from the cache provider and adds it to the request parameters to be included with the next request.
- allCapabilitiesPresent() — Returns true if all of the search_capabilities are present in the capabilities array that was returned from the WURFL Cloud Server
- callWurflCloud() — Make the webservice call to the server using the GET method and load the response.
- getUserAgent() — Return the requesting client's User Agent
- initializeRequest() — Initializes the WURFL Cloud request
- niceCast() — Casts strings into PHP native variable types, i.e. 'true' into true
- processResponse() — Parses the response into the capabilities array
- splitApiKey() — Splits the API Key into a username and password
- validateCache() — Checks if local cache is still valid based on the date that the WURFL Cloud Server was last updated. If auto_purge is enabled, this method will clear the cache provider if the cache is outdated.
public
- __construct() — Creates a new WurflCloud_Client instance
- detectDevice() — Get the requested capabilities from the WURFL Cloud for the given HTTP Request (normally $_SERVER)
- getAPIVersion() — Get the version of the WURFL Cloud Server. This is only available after a query has been made since it is returned in the response.
- getClientVersion() — Get the version of the WURFL Cloud Client (this file)
- getCloudServer() — Returns the Cloud server that was used
- getDeviceCapability() — Returns the value of the requested capability. If the capability does not exist, returns null.
- getLoadedDate() — Get the date that the WURFL Cloud Server was last updated. This will be null if there has not been a recent query to the server, or if the cached value was pushed out of memory
- getSource() — Gets the source of the result. Possible values: - cache: from local cache - cloud: from WURFL Cloud Service - none: no detection was performed @return string 'cache', 'cloud' or 'none'
- loadClass() — Loads Class files