You are here

public function MediaYouTubeTestHandler::getOEmbed in Media: YouTube 7.3

Returns information about the media.

See http://www.oembed.com.

Return value

If oEmbed information is available, an array containing 'title', 'type', 'url', and other information as specified by the oEmbed standard. Otherwise, NULL.

Overrides MediaInternetYouTubeHandler::getOEmbed

File

tests/includes/MediaYouTubeTestHandler.inc, line 14
Extends the MediaInternetYouTubeHandler class to make it suitable for local testing.

Class

MediaYouTubeTestHandler
A test handler for YouTube videos.

Code

public function getOEmbed() {
  $uri = $this
    ->parse($this->embedCode);
  $external_url = file_create_url($uri);
  $oembed_url = url('media-youtube-test/oembed', array(
    'query' => array(
      'url' => $external_url,
      'format' => 'json',
    ),
    'absolute' => TRUE,
  ));
  $response = drupal_http_request($oembed_url);
  if (!isset($response->error)) {
    return drupal_json_decode($response->data);
  }
  else {
    throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
    return;
  }
}