- Issue created by @grndlvl
At the moment the module only supports the global "Space API Key", however, we should also support the more specific "Project API Key".
The way that Usersnap handles this in their Wordpress module is by checking the endpoint to see if it exists.
/**
* Determine which widget type to load.
* returns the correct URL as string
*/
function get_widget_url($apiKey) {
$apiUrl = null;
// try platform
$headers = get_headers("https://widget.usersnap.com/load/" . $apiKey, 1);
if ($headers[0] == 'HTTP/1.1 200 OK') {
$apiUrl = "//widget.usersnap.com/load/" . $apiKey;
} else
{
// try global snippet
$headers = get_headers("https://widget.usersnap.com/global/load/" . $apiKey, 1);
if ($headers[0] == 'HTTP/1.1 200 OK') {
$apiUrl = "//widget.usersnap.com/global/load/" . $apiKey;
} else {
// invalidate widget_url since API key cannot be resolved by Usersnap endpoints
$apiUrl = null;
}
}
return $apiUrl;
}
We could do something similar or make it a setting.
Active
2.0
Code