You are here

function emfield_request_header in Embedded Media Field 5

Same name and namespace in other branches
  1. 6.3 deprecated/emfield-deprecated.inc \emfield_request_header()
  2. 6 emfield.module \emfield_request_header()
  3. 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' @param $url the url for the media @param $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 the header results returned as an array

5 calls to emfield_request_header()
emaudio_zzz_custom_url_data in contrib/emaudio/providers/zzz_custom_url.inc
video_cck_google_data in contrib/video_cck/providers/google.inc
hook emfield_PROVIDER_data
video_cck_livestream_data in contrib/video_cck/providers/livestream.inc
hook emfield_PROVIDER_data
video_cck_youtube_data in contrib/video_cck/providers/youtube.inc
hook emfield_PROVIDER_data
video_cck_zzz_custom_url_data in contrib/video_cck/providers/zzz_custom_url.inc

File

./emfield.module, line 817

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 unserialize($cache->data);
  }
  $result = _emfield_http_request_header($url);
  if ($result->code != 200) {
    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, 'cache', serialize($result), time() + variable_get('emfield_cache_duration', 3600));
  return $result;
}