function emfield_request_header in Embedded Media Field 6
Same name and namespace in other branches
- 5 emfield.module \emfield_request_header()
- 6.3 deprecated/emfield-deprecated.inc \emfield_request_header()
- 6.2 emfield.module \emfield_request_header()
Get the HTTP Header of media, for mime-type and length.
Parameters
$provider: The string of the third party provider, such as 'youtube', 'flikr', or 'google'.
$url: The url for the media.
$cached: Optional; if TRUE, the result of this xml request will be cached. good to play nice w/ the third party folks so they don't stop providing service to your site...
Return value
The header results, returned as an array.
5 calls to emfield_request_header()
- emaudio_custom_url_data in contrib/
emaudio/ providers/ custom_url.inc - emvideo_google_data in contrib/
emvideo/ providers/ google.inc - hook emfield_PROVIDER_data
- emvideo_twistage_data in contrib/
emvideo/ providers/ twistage.inc - Implementation of hook_PROVIDER_data().
- emvideo_youtube_data in contrib/
emvideo/ providers/ youtube.inc - hook emfield_PROVIDER_data
- emvideo_zzz_custom_url_data in contrib/
emvideo/ providers/ zzz_custom_url.inc
File
- ./
emfield.module, line 450 - Embedded Media Field is a CCK-based framework for 3rd party media files.
Code
function emfield_request_header($provider, $url, $cached = TRUE, $return_errors = TRUE) {
// if it's cacheable, try to load a cached value
if ($cached && ($cache = cache_get($url, 'cache'))) {
return $cache->data;
}
$result = _emfield_http_request_header($url);
if (!empty($result->error)) {
if ($return_errors) {
return $result;
}
emfield_set_error(t("Could not connect to @provider, HTTP error @error", array(
'@error' => $result->code,
'@provider' => $provider,
)));
return array();
}
// @todo does this not want to be changing 'cache' to 'cache_emfield' or similar
cache_set($url, $result, 'cache', time() + variable_get('emfield_cache_duration', 3600));
return $result;
}