public static function MediaInternetVimeoHandler::validId in Media: Vimeo 7.2
Check if a Vimeo video ID is valid.
Return value
boolean TRUE if the video ID is valid, or throws a MediaInternetValidationException otherwise.
1 call to MediaInternetVimeoHandler::validId()
File
- includes/
MediaInternetVimeoHandler.inc, line 88 - Extends the MediaInternetBaseHandler class to handle Vimeo videos.
Class
- MediaInternetVimeoHandler
- Implementation of MediaInternetBaseHandler.
Code
public static function validId($id) {
$uri = file_stream_wrapper_uri_normalize('vimeo://v/' . check_plain($id));
$external_url = file_create_url($uri);
$oembed_url = url('http://vimeo.com/api/oembed.json', array(
'query' => array(
'url' => $external_url,
),
));
$response = drupal_http_request($oembed_url, array(
'method' => 'HEAD',
));
if ($response->code == 401) {
throw new MediaInternetValidationException('Embedding has been disabled for this Vimeo video.');
}
elseif ($response->code != 200) {
throw new MediaInternetValidationException('The Vimeo video ID is invalid or the video was deleted.');
}
return TRUE;
}