The cloud service exposes meta data that can provide additional information about the various properties that might be returned.
The cloud service exposes meta data that can provide additional information about the various properties that might be returned.This example shows how to access this data and display the values available.
A list of the properties will be displayed, along with some additional information about each property. Note that this is the list of properties used by the supplied resource key, rather than all properties that can be returned by the cloud service.
In addition, the evidence keys that are accepted by the service are listed. These are the keys that, when added to the evidence collection in flow data, could have some impact on the result that is returned.
Bear in mind that this is a list of ALL evidence keys accepted by all products offered by the cloud. If you are only using a single product (for example - device detection) then not all of these keys will be relevant.
This example is available in full on GitHub.
To run this example, you will need to create a Resource Key.
The Resource Key stores your selected properties and any associated License Keys that allow more requests or access to paid properties.
You can create a Resource Key at
configure.51degrees.com.
Required Composer Dependencies:
<?php
require_once(__DIR__ . '/../../vendor/autoload.php');
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"]))
{
function main($argv)
{
$logger = new Logger("info");
$resourceKey = ExampleUtils::getResourceKeyFromEnv();
if (empty($resourceKey)) {
$resourceKey = ExampleUtils::getResourceKeyFromCliArgs($argv);
}
if (empty($resourceKey)) {
$message = "No resource key specified in CLI args or environment variable '" .
ExampleUtils::RESOURCE_KEY_ENV_VAR . "'." . PHP_EOL .
"The 51Degrees cloud service is accessed using a 'ResourceKey'. " .
"For more detail see " .
"/documentation/_services__cloud__resource_keys.html?utm_source=code&utm_medium=example&utm_campaign=51degrees-php&utm_content=examples-cloud-metadataconsole.php&utm_term=resource-key-required. " .
"A resource key with the properties required by this " .
"example can be created for free at " .
"https://configure.51degrees.com/1QWJwHxl?utm_source=code&utm_medium=example&utm_campaign=51degrees-php&utm_content=examples-cloud-metadataconsole.php&utm_term=resource-key-required. " .
"Once complete, populate the environment variable " .
"mentioned at the start of this message with the key.";
ExampleUtils::logErrorAndExit($logger, $message);
}
(new MetaDataConsole())->run($resourceKey, $logger, [ExampleUtils::class, 'output']);
}
main(isset($argv) ? array_slice($argv, 1) : null);
}
Definition ExampleUtils.php:29