function video_embed_field_handle_youtube_data in Video Embed Field 7.2
Gets video data for a YouTube video URL.
Parameters
string $url: A YouTube video URL to get data for
Return value
array|bool An array of video data, or FALSE if unable to fetch data
1 string reference to 'video_embed_field_handle_youtube_data'
File
- ./
video_embed_field.handlers.inc, line 254 - Provide some handlers for video embed field Other modules can implement the hook_video_embed_handler_info to provide more handlers.
Code
function video_embed_field_handle_youtube_data($url) {
// Get YouTube video ID from URL.
$id = _video_embed_field_get_youtube_id($url);
if ($id) {
$options['v'] = 3;
$options['key'] = variable_get('video_embed_field_youtube_v3_api_key', '');
$options['part'] = 'snippet';
$options['id'] = $id;
$response = drupal_http_request(url('https://www.googleapis.com/youtube/v3/videos', array(
'query' => $options,
)));
if (!isset($response->error)) {
$data = json_decode($response->data);
return _video_embed_field_clean_up_youtube_data($data->items);
}
}
return FALSE;
}