public function MediaInternetYouTubeHandler::getOEmbed in Media: YouTube 7.3
Same name and namespace in other branches
- 7 includes/MediaInternetYouTubeHandler.inc \MediaInternetYouTubeHandler::getOEmbed()
- 7.2 includes/MediaInternetYouTubeHandler.inc \MediaInternetYouTubeHandler::getOEmbed()
Returns information about the media.
Return value
If oEmbed information is available, an array containing 'title', 'type', 'url', and other information as specified by the oEmbed standard. Otherwise, NULL.
1 call to MediaInternetYouTubeHandler::getOEmbed()
1 method overrides MediaInternetYouTubeHandler::getOEmbed()
- MediaYouTubeTestHandler::getOEmbed in tests/
includes/ MediaYouTubeTestHandler.inc - Returns information about the media.
File
- includes/
MediaInternetYouTubeHandler.inc, line 88 - Extends the MediaInternetBaseHandler class to handle YouTube videos.
Class
- MediaInternetYouTubeHandler
- Implementation of MediaInternetBaseHandler.
Code
public function getOEmbed() {
$uri = $this
->parse($this->embedCode);
$external_url = file_create_url($uri);
$oembed_url = url('https://www.youtube.com/oembed', array(
'query' => array(
'url' => $external_url,
'format' => 'json',
),
));
$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})");
}
}