public function Media23VideoInternetHandler::getOEmbed in Media 23video 7
Returns information about the media.
@link http://www.oembed.com/
Parameters
array $params: URL query parameters.
Return value
array Embed data.
See also
url()
2 calls to Media23VideoInternetHandler::getOEmbed()
- Media23VideoInternetHandler::getFileObject in includes/
Media23VideoInternetHandler.inc - Returns a file object which can be used for validation.
- Media23VideoInternetHandler::parse in includes/
Media23VideoInternetHandler.inc - Check if a 23Video video ID valid.
File
- includes/
Media23VideoInternetHandler.inc, line 104 - Definition of Media23VideoInternetHandler object.
Class
- Media23VideoInternetHandler
- Class Media23VideoInternetHandler.
Code
public function getOEmbed(array $params = array()) {
$cache_key = implode(':', array_merge(array_values($params), array_keys($params), array(
$this->embedCode,
)));
$cache = cache_get($cache_key);
if (empty($cache->data)) {
$url = parse_url($this->embedCode);
if (isset($url['host'])) {
$request = url($url['scheme'] . '://' . $url['host'] . '/oembed', array(
'query' => $params + array(
'url' => $this->embedCode,
'format' => 'json',
),
));
$response = drupal_http_request($request);
if (empty($response->error)) {
$data = drupal_json_decode($response->data);
cache_set($cache_key, $data);
return $data;
}
else {
watchdog(MEDIA_23VIDEO_MODULE_TITLE, 'The next error was received when requesting on @url: @error', array(
'@url' => $request,
'@error' => $response->error,
), WATCHDOG_ERROR);
}
}
}
else {
return $cache->data;
}
return array();
}