function tripal_get_remote_context
3.x tripal_ws.api.inc | tripal_get_remote_context($context_url, $cache_id) |
Retrieves the JSON-LD context for any remote Tripal web service.
Parameters
$context_url: The Full URL for the context file on the remote Tripal site. This URL can be found in the '@context' key of any response from a remote Tripal web services call.
$cache_id: A unique ID for caching of this context result to speed furture queries.
Return value
The JSON-LD context mapping array, or FALSE if the context could not be retrieved.
Related topics
1 call to tripal_get_remote_context()
- tripal_get_remote_content_context in tripal_ws/
api/ tripal_ws.api.inc - Retrieves the JSON-LD context for a bundle or field on a remote Tripal site.
File
- tripal_ws/
api/ tripal_ws.api.inc, line 295 - This file provides the Tripal Web Services API: a set of functions for interacting with the Tripal Web Services.
Code
function tripal_get_remote_context($context_url, $cache_id) {
if (!$context_url) {
throw new Exception('PLease provide a context_url for the tripal_get_remote_context function.');
}
if (!$cache_id) {
throw new Exception('PLease provide unique $cache_id for the tripal_get_remote_context function.');
}
if ($cache = cache_get($cache_id)) {
return $cache->data;
}
$context = drupal_http_request($context_url);
if (!$context) {
tripal_report_error('tripal_ws', TRIPAL_ERROR,
'There was a poblem retrieving the context from the remote site: !context_url.',
array('!context_url' => $context_url));
return FALSE;
}
$context = drupal_json_decode($context->data);
$context = $context['@context'];
cache_set($cache_id, $context);
return $context;
}